GDocsService

Description

In BBj 11.0 and higher, the GDocsService class is one of the BBj CustomObjects that comprises the GApps utility. This class can used in a BBj application to interface with one of the Google Docs services.

Creation

The GDocsService class is found in <bbj install>/utils/gapps/gapps.bbj.

GDocsService()

Parameters

None.

Methods of GDocsService

Return Value

Method

void

createFolder(string folderName)

static DocsService

getDocsService()

GDoc

getDocument(string resourceID)

GDoc

getDocument(string title, string type, boolean createIfNeeded)

GDoc

getDocument(string title, string type, string mimeType, string folder, boolean createIfNeeded)

GDoc

uploadDocument(string fileName, string title, string type, string folder, boolean convert)

GDoc

uploadDocument(string fileName, string title, string type, string folder, boolean convert, boolean overwrite)

Methods inherited from GAppsService

Return Value

Method

int

doLoginDialog()

string

getPassword()

string

getUser()

string

getUserToken()

boolean

isAuthenticated(boolean promptUser)

void

resetAuthentication()

void

setUserCredentials(string user, string password)

void

setUserCredentials(string user, string password)

void

setUserToken(string token)

void

setUserToken(string token, boolean remember)

Remarks

This class extends a GAppsService.

Constants

Name

Value

FILE_NOT_FOUND_ERROR

303

DOC_NOT_FOUND_ERROR

304

UPLOAD_ERROR

305

CREATE_ERROR

306

ALREADY_EXISTS_ERROR

307

Example

rem Use statements
use ::gapps.bbj::GDocFolderSelectionDialog
use ::gapps.bbj::GDocSaveDialog
use ::gapps.bbj::GDocOpenDialog
use ::gapps.bbj::GDoc

rem Run a demo  

rem mode$="folder"
rem mode$="save"

rem Create a folder selection dialog
declare GDocFolderSelectionDialog folderSelectionDialog!
folderSelectionDialog! = new GDocFolderSelectionDialog()
rc = folderSelectionDialog!.doModal()

if (rc = GDocFolderSelectionDialog.getSELECTED())
  documentFolder$ = folderSelectionDialog!.getDocumentFolder()
  x=MsgBox(documentFolder$,0,"Selected folder")
endif

rem Create a save dialog
declare GDocSaveDialog saveDialog!
saveDialog! = new GDocSaveDialog()
saveDialog!.setDefaultType(GDoc.getSPREADSHEET_TYPE())
rc = saveDialog!.doModal()

if (rc = GDocSaveDialog.getSELECTED())
  title$ = saveDialog!.getDocumentTitle()
  type$ = saveDialog!.getDocumentType()
  folder$ = saveDialog!.getDocumentFolder()
  x=MsgBox(folder$ +"/" + title$,0,"Selected document")
endif

rem Create a open dialog
declare GDocOpenDialog openDialog!
openDialog! = new GDocOpenDialog()
openDialog!.setTitle("Google Documents")
openDialog!.setMultipleSelection(1)

rc = openDialog!.doModal()

if (rc = GDocOpenDialog.getSELECTED())
  declare BBjVector selectedDocs!    

  selectedDocs! = openDialog!.getSelectedDocs()
  numSelectedDocs = selectedDocs!.size()

  if (numSelectedDocs > 0)
      for i = 0 to numSelectedDocs-1
          declare GDoc selectedDoc!
          selectedDoc! = cast(GDoc,selectedDocs!.getItem(i))
          selectedDoc!.openInBrowser()
      next i
  endif
endif

release

See Also

BBj Object Syntax

GApps

GAppsService

GCalendarService

GSitesService