lib: removed dead code from Bookmark parser
[barry/progweb.git] / desktop / src / CUI_Google.cc
blobc20beceb323e2c7e33d31eeffe008f7c25a856fd
1 ///
2 /// \file CUI_Google.cc
3 /// ConfigUI derived class to configure the Google App
4 ///
6 /*
7 Copyright (C) 2010-2012, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #include "CUI_Google.h"
23 //#include "os22.h" // only for the dynamic_cast
24 #include <wx/wx.h>
25 #include <wx/process.h>
26 #include <gcalendar.h>
27 #include <sstream>
29 using namespace std;
31 namespace AppConfig {
33 //////////////////////////////////////////////////////////////////////////////
34 // Google config UI class
36 Google::Google()
37 : m_google(0)
38 , m_parent(0)
40 // gcal_t google_calendar = gcal_new(GCALENDAR);
41 // gcal_get_authentication(google_calendar, "username", "password");
44 std::string Google::AppName() const
46 return OpenSync::Config::Google::AppName();
49 bool Google::Configure(wxWindow *parent, plugin_ptr old_plugin)
51 m_parent = parent;
53 // create our plugin config
54 m_google = dynamic_cast<OpenSync::Config::Google*> (old_plugin.get());
55 if( m_google ) {
56 m_google = m_google->Clone();
58 else {
59 m_google = new OpenSync::Config::Google;
61 m_container.reset( m_google );
63 // display dialog and let user fill in the details
64 return false; // FIXME - not finished
67 ConfigUI::plugin_ptr Google::GetPlugin()
69 m_google = 0;
70 return m_container;
73 bool Google::RunApp(wxWindow *parent)
75 return false;
78 void Google::PreSyncAppInit()
82 bool Google::ZapData(wxWindow *parent,
83 plugin_ptr plugin,
84 OpenSync::API *engine)
86 m_parent = parent;
88 // extract OpenSync::Config::Google from plugin
89 // this *can* throw an exception if the wrong plugin is
90 // passed in, but we want this... such an exception would
91 // represent a bug in the app, not a runtime error
92 OpenSync::Config::Google &google =
93 dynamic_cast<OpenSync::Config::Google&>(*plugin);
95 // build intro message
96 ostringstream oss;
97 oss << "Please select the databases you wish to erase\n"
98 "in your Google Calendar: \n"
99 "\n"
100 "Note: all synced databases must be erased\n"
101 "to avoid a slow-sync.";
102 wxString msg(oss.str().c_str(), wxConvUTF8);
104 // build list of databases (base on information from engine, if
105 // the pointer is valid)
106 wxArrayString dbs;
107 wxArrayInt selections;
108 dbs.Add( _T("Calendar") ); selections.Add(0);
109 dbs.Add( _T("Contacts") ); selections.Add(1);
111 // present the list to the user
112 int count = wxGetMultipleChoices(selections, msg,
113 _T("Select Databases to Erase"), dbs, m_parent);
114 if( count <= 0 )
115 return false; // nothing to do
117 // display selections to the user for one final confirmation
118 oss.str("");
119 oss << "You have selected the following databases to be completely "
120 "erased from your Google Calendar:\n\n";
121 for( size_t i = 0; i < selections.GetCount(); i++ ) {
122 oss << string(dbs[selections[i]].utf8_str()) << "\n";
124 oss << "\nProceed with erase?";
125 wxString confirm(oss.str().c_str(), wxConvUTF8);
126 int choice = wxMessageBox(confirm, _T("Erase Confirmation"),
127 wxYES_NO | wxICON_QUESTION, m_parent);
128 if( choice != wxYES )
129 return false; // nothing to do
131 // might be busy for a bit
132 wxBusyCursor wait;
134 // connect to Google Calendar and delete all selected databases
135 (void)google;
136 return false; // FIXME - not finished
139 } // namespace AppConfig