2 /// \file CUI_Google.cc
3 /// ConfigUI derived class to configure the Google App
7 Copyright (C) 2010-2013, 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"
24 #include <wx/process.h>
25 #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
96 wxString msg
= _W("Please select the databases you wish to erase\n"
97 "in your Google Calendar: \n"
99 "Note: all synced databases must be erased\n"
100 "to avoid a slow-sync.");
102 // build list of databases (base on information from engine, if
103 // the pointer is valid)
105 wxArrayInt selections
;
106 dbs
.Add( _W("Calendar") ); selections
.Add(0);
107 dbs
.Add( _W("Contacts") ); selections
.Add(1);
109 // present the list to the user
110 int count
= wxGetMultipleChoices(selections
, msg
,
111 _W("Select Databases to Erase"), dbs
, m_parent
);
113 return false; // nothing to do
115 // display selections to the user for one final confirmation
117 oss
<< _C("You have selected the following databases to be completely "
118 "erased from your Google Calendar:") << "\n\n";
119 for( size_t i
= 0; i
< selections
.GetCount(); i
++ ) {
120 oss
<< string(dbs
[selections
[i
]].utf8_str()) << "\n";
122 oss
<< "\n" << _C("Proceed with erase?");
123 wxString
confirm(oss
.str().c_str(), wxConvUTF8
);
124 int choice
= wxMessageBox(confirm
, _W("Erase Confirmation"),
125 wxYES_NO
| wxICON_QUESTION
, m_parent
);
126 if( choice
!= wxYES
)
127 return false; // nothing to do
129 // might be busy for a bit
132 // connect to Google Calendar and delete all selected databases
134 return false; // FIXME - not finished
137 } // namespace AppConfig