2 /// \file CUI_Google.cc
3 /// ConfigUI derived class to configure the Google App
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
25 #include <wx/process.h>
26 #include <gcalendar.h>
33 //////////////////////////////////////////////////////////////////////////////
34 // Google config UI class
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
)
53 // create our plugin config
54 m_google
= dynamic_cast<OpenSync::Config::Google
*> (old_plugin
.get());
56 m_google
= m_google
->Clone();
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()
73 bool Google::RunApp(wxWindow
*parent
)
78 void Google::PreSyncAppInit()
82 bool Google::ZapData(wxWindow
*parent
,
84 OpenSync::API
*engine
)
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
97 oss
<< "Please select the databases you wish to erase\n"
98 "in your Google Calendar: \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)
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
);
115 return false; // nothing to do
117 // display selections to the user for one final confirmation
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
134 // connect to Google Calendar and delete all selected databases
136 return false; // FIXME - not finished
139 } // namespace AppConfig