Click here to Skip to main content
15,879,474 members
Articles / Desktop Programming / MFC

A Google Docs Based Backup Application

Rate me:
Please Sign up or sign in to vote.
4.89/5 (71 votes)
20 Mar 2015CPOL4 min read 98.2K   3.9K   121  
A C++ client for uploading documents to your Google Docs account
#pragma once

#define GOOGLE_XML_FEED                     L"feed"
#define GOOGLE_XML_ENTRY                    L"entry"
#define GOOGLE_XML_TITLE                    L"title"
#define GOOGLE_XML_ID                       L"id"
#define GOOGLE_XML_LINK                     L"link"
#define GOOGLE_XML_REL                      L"rel"
#define GOOGLE_XML_LINKRELNEXT              L"next"
#define GOOGLE_XML_PARENTLINKREL            L"http://schemas.google.com/docs/2007#parent"
#define GOOGLE_XML_HREF                     L"href"
#define GOOGLE_XML_ENTRY_CONTENT            L"content"
#define GOOGLE_XML_ENTRY_CONTENT_TYPE       L"type"
#define GOOGLE_XML_ENTRY_CONTENT_SRC        L"src"
#define GOOGLE_XML_GD_RESOURCEID            L"gd:resourceId"

typedef vector<const struct _GOOGLE_FOLDER_DESCR> folder_list;
typedef struct _GOOGLE_FOLDER_DESCR
{
  str::hash_string id;
  wstring title;
  folder_list children;

  _GOOGLE_FOLDER_DESCR() { ; }
  _GOOGLE_FOLDER_DESCR(const str::hash_string &_id, const wstring &_title);

} GOOGLE_FOLDER_DESCR;

typedef vector<wstring> path_vector;

typedef struct _GOOGLE_FILE_DESCR
{
  wstring title;
  wstring id;
  wstring gdResourceType;
  wstring contentType;
  wstring contentSrc;
} GOOGLE_FILE_DESCR;

class CGoogleFolderTree
{
public:
  typedef struct
  {
    BOOL processed;
    str::hash_string id;
    str::hash_string parent_id;
    wstring title;
  } GOOGLE_FOLDER_BD;

  static void BuildFolderTree(GOOGLE_FOLDER_DESCR &googleFolderTree, vector<GOOGLE_FOLDER_BD> &folders);
  static const wstring &RootFolderId();
  static wstring ExtractIdFromIdRef(const wstring &https_id_folder);
  static BOOL AddFiles(size_t &entriesProcessed, vector<GOOGLE_FILE_DESCR> &files, wstring &nextHref, const string &filesXml, const wstring &parentFolderId);
  static BOOL AddFolders(size_t &entriesProcessed, vector<GOOGLE_FOLDER_BD> &folders, wstring &nextHref, const string &foldersXml);
private:

  static wstring StrWithoutPrefix(const wstring &s, size_t prefixLength);
  static void BuildFolderChildren(GOOGLE_FOLDER_DESCR &folderDescr, vector<GOOGLE_FOLDER_BD> &folders, size_t &toProcess);
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
CEO Secured Globe, Inc.
United States United States
Michael Haephrati is a music composer, an inventor and an expert specializes in software development and information security, who has built a unique perspective which combines technology and the end user experience. He is the author of a the book Learning C++ , which teaches C++ 20, and was published in August 2022.

He is the CEO of Secured Globe, Inc., and also active at Stack Overflow.

Read our Corporate blog or read my Personal blog.





Comments and Discussions