This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This is main kick off after the app inits, the views and Settings are setup here. (preferred - iOS4 and up) | |
*/ | |
- (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions | |
{ | |
// there will be more code in this method for your PhoneGap application | |
// code needed for Dropbox - Do not forget this | |
DBSession* dbSession = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********* PhoneGapDropbox.m Cordova Plugin Implementation *******/ | |
#import "PhoneGapDropbox.h" | |
#import <Cordova/CDV.h> | |
#import <DropboxSDK/DropboxSDK.h> // import the DropboxSDK | |
#import "AppDelegate.h" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********* PhoneGapDropbox.h Cordova Plugin Header *******/ | |
#import <Cordova/CDV.h> | |
#import <DropboxSDK/DropboxSDK.h> | |
DBRestClient *restClient; // declare REST client instance var to use file upload/download methods | |
NSString* restoreJavaScript = nil; // declare restoreJavaScript instance var for restore JavaScript callback | |
@interface PhoneGapDropbox : CDVPlugin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function linkDropbox(){ // start the Dropbox link process, make a button call this function on click | |
cordova.exec(linkDropboxCB, linkDropboxFail, "PhoneGapDropBox", "link", [""]); | |
} | |
function linkDropboxCB(){ // this callback fires if the link method in PhoneGapDropbox.m is successful | |
console.log("link method in PhoneGapDropbox.m executed successfully"); | |
} | |
function linkDropboxFail(err){ // this fail callback fires if the link method in PhoneGapDropbox.m fails | |
console.log("linkDropboxFail() - error message is below"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//start the Dropbox authentication process, "link" this app to your Dropbox account | |
function linkDropbox(){ | |
cordova.exec(linkDropboxCB, linkDropboxFail, "PhoneGapDropBox", "link", [""]); | |
//exec(<successFunction>, <failFunction>, <service>, <action>, [<args>]); | |
//This will marshall a request from the WebView to the Android native side, more or less boiling down to | |
//calling the action method on the service class, with the arguments passed in the args Array. | |
} | |
var dropBoxAuthAttempt = false; // set this global var so authDropbox() is only called once | |
function linkDropboxCB(){ // this callback is only ran if the native Java call in linkDropbox() was successful |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.xyz.xyz; // your package name here | |
import org.apache.cordova.api.Plugin; | |
import org.apache.cordova.api.PluginResult; | |
import org.json.JSONArray; | |
import org.json.JSONException; | |
import org.json.JSONObject; | |
// import everything needed for Dropbox functionality | |
import android.content.Context; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GCDAsyncSocket delegate, called when the server (device receiving JSON) accepts an incoming client connection. another socket is spawned to handle it. | |
- (void)socket:(GCDAsyncSocket *)sender didAcceptNewSocket:(GCDAsyncSocket *)newSocket | |
{ | |
// The "sender" parameter is the listenSocket we created. | |
// The "newSocket" is a new instance of GCDAsyncSocket. | |
// It represents the accepted incoming client connection. | |
// Do server stuff with newSocket... | |
NSLog(@"Accepted new socket from %@:%hu", [newSocket connectedHost], [newSocket connectedPort]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GCDAsyncSocket delegate, this occurs when the server has sent the message asking the client to send JSON | |
- (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag | |
{ | |
if (tag == TAG_ASK_FOR_JSON) { | |
NSLog(@"didWriteDataWithTag tag (TAG_ASK_FOR_JSON) in SocketServerDelegate.m - First Request sent from server to device sending JSON, asking it to send JSON data"); | |
// Now start the queue to read in the JSON stream from the client | |
[sock readDataToData:[GCDAsyncSocket CRLFData] withTimeout:-1 tag:TAG_READ_JSON_DATA]; // parse all the way to CRLF | |
// You can even specify what should be used as a terminator for a byte stream |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(SELECT 'lab' AS table_name, id FROM table1 | |
WHERE organizerClassId = '4013-5' LIMIT 1) | |
UNION | |
(SELECT 'rad' AS table_name, id FROM table2 | |
WHERE organizerClassId = '4013-5' LIMIT 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM ( | |
SELECT 'lab' AS table_name, id FROM table1 | |
WHERE organizerClassId = '4013-5' LIMIT 1) | |
UNION | |
SELECT * FROM ( | |
SELECT 'rad' AS table_name, id FROM table2 | |
WHERE organizerClassId = '4013-5' LIMIT 1); |
OlderNewer