Bumped copyright dates for 2013
[barry.git] / desktop / src / CUI_Google.cc
blob5d6a0fd736fe9a7c056cab9e762c650d26b927b9
1 ///
2 /// \file CUI_Google.cc
3 /// ConfigUI derived class to configure the Google App
4 ///
6 /*
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"
23 #include <wx/wx.h>
24 #include <wx/process.h>
25 #include <gcalendar.h>
26 #include <sstream>
27 #include "wxi18n.h"
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 wxString msg = _W("Please select the databases you wish to erase\n"
97 "in your Google Calendar: \n"
98 "\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)
104 wxArrayString dbs;
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);
112 if( count <= 0 )
113 return false; // nothing to do
115 // display selections to the user for one final confirmation
116 ostringstream oss;
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
130 wxBusyCursor wait;
132 // connect to Google Calendar and delete all selected databases
133 (void)google;
134 return false; // FIXME - not finished
137 } // namespace AppConfig