davibe/Phonegap-SQLitePlugin

Cordova support

coomsie opened this issue · 13 comments

I think you need to update this in your PGSQLitePlugin.h

#import <Foundation/Foundation.h>
#import "sqlite3.h"

#ifdef CORDOVA_FRAMEWORK
#import <CORDOVA/CDVPlugin.h>
#import <CORDOVA/JSONKit.h>
#import <CORDOVA/CDVFile.h>
#else
#import "CDVPlugin.h"
#import "JSON.h"
#import "File.h"
#endif

#import "AppDelegate.h"

@interface PGSQLitePlugin : CDVPlugin {
    NSMutableDictionary *openDBs;
}

and this in your m file....

-(CDVPlugin*) initWithWebView:(UIWebView*)theWebView
{
    self = (PGSQLitePlugin*)[super initWithWebView:theWebView];
    if (self) {
        openDBs = [NSMutableDictionary dictionaryWithCapacity:0];
        [openDBs retain];

        CDVFile* pgFile = [[self appDelegate] getCommandInstance: @"com.phonegap.file"];
        NSString *docs = [pgFile appDocsPath];
        [self setAppDocsPath:docs];

    }
    return self;
}

plus in your plugin file you will need to replace PhoneGap.execute with Cordova.

===> Though I haven't got it working yet ...

looks like the plugin js file needs a change around for a newer architecture , maybe?

Interesting project by the way ...

Thanks for the infos.

Unfortunately I don't have a lot of time to look into it these days.

It has to be done though .. so .. I will

Davide Bertola

On Mar 18, 2012, at 11:23 AM, coomsie wrote:

I think you need to update this in your PGSQLitePlugin.h

#import <Foundation/Foundation.h>
#import "sqlite3.h"

#ifdef CORDOVA_FRAMEWORK
#import <CORDOVA/CDVPlugin.h>
#import <CORDOVA/JSONKit.h>
#import <CORDOVA/CDVFile.h>
#else
#import "CDVPlugin.h"
#import "JSON.h"
#import "File.h"
#endif

#import "AppDelegate.h"

@interface PGSQLitePlugin : CDVPlugin {
   NSMutableDictionary *openDBs;
}

and this in your m file....

-(CDVPlugin*) initWithWebView:(UIWebView*)theWebView
{
   self = (PGSQLitePlugin*)[super initWithWebView:theWebView];
   if (self) {
       openDBs = [NSMutableDictionary dictionaryWithCapacity:0];
       [openDBs retain];

       CDVFile* pgFile = [[self appDelegate] getCommandInstance: @"com.phonegap.file"];
       NSString *docs = [pgFile appDocsPath];
       [self setAppDocsPath:docs];

   }
   return self;
}

plus in your plugin file you will need to replace PhoneGap.execute with Cordova.

===> Though I haven't got it working yet ...

looks like the plugin js file needs a change around for a newer architecture , maybe?

Interesting project by the way ...


Reply to this email directly or view it on GitHub:
#14

I got the problem with JSON.h for both PhoneGap 1.3 and Cordova (PhoneGap 1.5)?

Where can I get JSON.h?

Is it the same with JSONKit.h?

I am using Xcode 3.2.6 (iOS 4.3 SDK).

Thanks.

Edited: OK. I got it. We need JSON framework to make this error go away.

http://code.google.com/p/json-framework/downloads/detail?name=JSON_2.2.dmg&can=1&q=

Now, File.h is missing again.

What framework is File.h included?

Not working, mixing Cordova and PhoneGap framework.

@coomsie, if you want a PhoneGap 1.3.0 with iPhone, I can share my dropbox

Noli

I would make another suggestion to rename the plugin from PGSQLitePlugin to SQLitePlugin for slightly better consistency with other PhoneGap/Cordova plugins. I am busy for the next few weeks with an urgent project and will be happy to try working on this issue once the project is delivered.

In addition, people may be interested in Apahe Cordova CB-330 with an incubator change to make the SQLite database in the WebKit store the data in a permanent location. It is very interesting to see how they are handling the SQLite in the main Cordova library, however I am afraid that if an app or even a device would crash there could be some SQLite user data that is not backed up. What I like about this plugin is that I believe it does provide a more fail-safe solution for apps that are storing important user data.

Ian aka Coomsie managed to port this plugin into Cordova_SQLitePlugin.

However, there is problem - "Cannot create a CDVSQLitePlugin instance without a dbPath"

coomsie/Cordova_SQLitePlugin#1

He converted all the javascript that goes with the plugin as far I can see.

looks like it's sorted .. have a look if you want ...

Is there any reason the project coomsie/Cordova_SQLitePlugin is/was not registered as a fork of davibe/Phonegap-SQLitePlugin?

No reason.

Happy to change

Cheers
Iain

Sent from my iPhone 4

On 27/03/2012, at 3:39 AM, Chris Brodyreply@reply.github.com wrote:

Is there any reason the project coomsie/Cordova_SQLitePlugin is/was not registered as a fork of davibe/Phonegap-SQLitePlugin?


Reply to this email directly or view it on GitHub:
#14 (comment)

Hi Iain,

Only change it if it is easy for you, this is like "starting over" as far as github is concerned. Is it an idea to get rid of the PG/CDV prefix in the class name[s]?

Also, how hard would it be to fix the returned db object to follow the HTML5 Web SQL API? Do you want to do this or is it better to leave it for someone else, such as myself, for the future?

Thanks,
Chris

@coomsie I just tried your version in Cordova and it works great, nice work!

@coomsie, Nice job. Thanks. It is working perfectly. Now, we can
create not just 1 sqlite3 database but more.

Noli

On 3/27/12, Chris Brody
reply@reply.github.com
wrote:

@coomsie I just tried your version in Cordova and it works great, nice work!


Reply to this email directly or view it on GitHub:
#14 (comment)

mmm.

I did notice that plus some other things as well ...

I would like to change the js style too as i find it hard to work with as
it is.

I'll change to fork it and change some naming conventions .... tonight

then i want to try a few tests out for a project im doing ... as I'm using
Ti instead of phonegap, but wanted to have the db native and work with
html side for leaflet ...

if it looks like performance hasnt suffered i will then push on and try
some of those changes u suggested.

Cheers
Iain

On Tue, Mar 27, 2012 at 7:48 AM, Chris Brody <
reply@reply.github.com

wrote:

Hi Iain,

Only change it if it is easy for you, this is like "starting over" as far
as github is concerned. Is it an idea to get rid of the PG/CDV prefix in
the class name[s]?

Also, how hard would it be to fix the returned db object to follow the
HTML5 Web SQL API? Do you want to do this or is it better to leave it for
someone else, such as myself, for the future?

Thanks,
Chris


Reply to this email directly or view it on GitHub:

#14 (comment)

Cheers
Coomsie