3 /// Class for the fixed-size frame that holds the main app
7 Copyright (C) 2009-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 "BaseFrame.h"
23 #include "Mode_MainMenu.h"
24 #include "Mode_Sync.h"
25 #include "Mode_Browse.h"
26 #include "MigrateDlg.h"
28 #include "ClickImage.h"
29 #include "barrydesktop.h"
30 #include "windowids.h"
32 #include <wx/aboutdlg.h>
36 // include icons and logos
37 #include "../images/barry_logo_icon.xpm"
38 #include "../images/logo_NetDirect.xpm"
42 BEGIN_EVENT_TABLE(BaseFrame
, wxFrame
)
43 EVT_SIZE (BaseFrame::OnSize
)
44 EVT_PAINT (BaseFrame::OnPaint
)
45 EVT_MOTION (BaseFrame::OnMouseMotion
)
46 EVT_LEFT_DOWN (BaseFrame::OnLeftDown
)
47 EVT_LEFT_UP (BaseFrame::OnLeftUp
)
48 EVT_BUTTON (MainMenu_BackupAndRestore
, BaseFrame::OnBackupRestore
)
49 EVT_BUTTON (MainMenu_Sync
, BaseFrame::OnSync
)
50 EVT_BUTTON (MainMenu_Modem
, BaseFrame::OnModem
)
51 EVT_BUTTON (MainMenu_AppLoader
, BaseFrame::OnAppLoader
)
52 EVT_BUTTON (MainMenu_MigrateDevice
, BaseFrame::OnMigrateDevice
)
53 EVT_BUTTON (MainMenu_BrowseDatabases
, BaseFrame::OnBrowseDatabases
)
54 EVT_BUTTON (MainMenu_MediaManagement
, BaseFrame::OnMediaManagement
)
55 EVT_BUTTON (MainMenu_Misc
, BaseFrame::OnMisc
)
56 EVT_BUTTON (MainMenu_BackButton
, BaseFrame::OnBackButton
)
57 EVT_BUTTON (HotImage_BarryLogo
, BaseFrame::OnBarryLogoClicked
)
58 EVT_BUTTON (HotImage_NetDirectLogo
, BaseFrame::OnNetDirectLogoClicked
)
59 EVT_TEXT (Ctrl_DeviceCombo
, BaseFrame::OnDeviceComboChange
)
60 EVT_MENU (SysMenu_VerboseLogging
, BaseFrame::OnVerboseLogging
)
61 EVT_MENU (SysMenu_RenameDevice
, BaseFrame::OnRenameDevice
)
62 EVT_MENU (SysMenu_ResetDevice
, BaseFrame::OnResetDevice
)
63 EVT_MENU (SysMenu_RescanUsb
, BaseFrame::OnRescanUsb
)
64 EVT_MENU (SysMenu_About
, BaseFrame::OnAbout
)
65 EVT_MENU (SysMenu_Exit
, BaseFrame::OnExit
)
66 EVT_END_PROCESS (Process_BackupAndRestore
, BaseFrame::OnTermBackupAndRestore
)
69 //////////////////////////////////////////////////////////////////////////////
72 BaseFrame::BaseFrame(const wxImage
&background
)
73 : wxFrame(NULL
, wxID_ANY
, _W("Barry Desktop Control Panel"),
75 wxSize(background
.GetWidth(), background
.GetHeight()),
76 wxMINIMIZE_BOX
| wxCAPTION
| wxCLOSE_BOX
| wxSYSTEM_MENU
|
78 , TermCatcher(this, Process_BackupAndRestore
)
79 , m_width(background
.GetWidth())
80 , m_height(background
.GetHeight())
82 , m_backup_process(this)
83 , m_rescan_pending(false)
85 // This is a workaround for different size behaviour
86 // in the GTK version of wxWidgets 2.9
87 SetClientSize(wxSize(background
.GetWidth(), background
.GetHeight()));
90 m_background
.reset( new wxBitmap(background
) );
92 // the main menu mode always exists, but may not always be current
93 m_main_menu_mode
.reset( new MainMenuMode(this) );
94 m_current_mode
= m_main_menu_mode
.get();
96 m_barry_logo
.reset( new ClickableImage(this,
97 wxBitmap(barry_logo_icon_xpm
), HotImage_BarryLogo
,
99 wxBitmap
nd_logo(logo_NetDirect_xpm
);
100 m_netdirect_logo
.reset( new ClickableImage(this,
101 nd_logo
, HotImage_NetDirectLogo
,
102 m_width
- 3 - nd_logo
.GetWidth(),
103 (MAIN_HEADER_OFFSET
- nd_logo
.GetHeight()) / 2, true,
106 // Create the Barry Logo popup system menu
107 m_sysmenu
.reset( new wxMenu
);
108 m_sysmenu
->Append( new wxMenuItem(m_sysmenu
.get(),
109 SysMenu_VerboseLogging
, _W("&Verbose Logging"),
110 _W("Enable low level USB debug output"), wxITEM_CHECK
, NULL
) );
111 m_sysmenu
->Append(SysMenu_RenameDevice
, _W("Re&name Device..."));
112 m_sysmenu
->Append(SysMenu_ResetDevice
, _W("Re&set Device"));
113 m_sysmenu
->Append(SysMenu_RescanUsb
, _W("&Rescan USB"));
114 m_sysmenu
->AppendSeparator();
115 m_sysmenu
->Append(SysMenu_About
, _W("&About..."));
116 m_sysmenu
->AppendSeparator();
117 m_sysmenu
->Append(wxID_EXIT
, _W("E&xit"));
120 CreateDeviceCombo(wxGetApp().GetGlobalConfig().GetLastDevice());
123 void BaseFrame::UpdateMenuState()
125 if( !m_sysmenu
.get() )
128 wxMenuItemList
&list
= m_sysmenu
->GetMenuItems();
129 wxMenuItemList::iterator b
= list
.begin();
130 for( ; b
!= list
.end(); ++b
) {
131 wxMenuItem
*item
= *b
;
133 switch( item
->GetId() )
135 case SysMenu_VerboseLogging
:
136 item
->Check(Barry::IsVerbose());
142 void BaseFrame::CreateDeviceCombo(Barry::Pin pin
)
144 const Barry::Probe::Results
&results
= wxGetApp().GetResults();
147 // no device selected, if multiple available and no default given
148 // no devices available, if nothing there
149 // the first device, if only one exists
152 // create a list of selections
153 wxArrayString devices
;
155 // if there's more than one device, let the user pick "none"
156 if( results
.size() > 1 ) {
157 devices
.Add(_W("No device selected"));
160 // add one entry for each device
161 for( Barry::Probe::Results::const_iterator i
= results
.begin();
162 i
!= results
.end(); ++i
)
164 // if this is the desired item, remember this selection
165 if( pin
.Valid() && i
->m_pin
== pin
) {
166 selected
= devices
.GetCount();
169 devices
.Add(wxString(i
->GetDisplayName().c_str(), wxConvUTF8
));
172 // if nothing is there, be descriptive
173 if( devices
.GetCount() == 0 ) {
174 devices
.Add(_W("No devices available"));
177 // create the combobox
178 int x
= m_width
- 300;
179 int y
= m_height
- (MAIN_HEADER_OFFSET
- 5);
180 m_device_combo
.reset( new wxComboBox(this, Ctrl_DeviceCombo
, _T(""),
181 wxPoint(x
, y
), wxSize(290, -1), devices
, wxCB_READONLY
) );
183 // select the desired entry
184 m_device_combo
->SetValue(devices
[selected
]);
186 // update the screenshot
187 m_main_menu_mode
->UpdateScreenshot(GetCurrentComboPin());
190 Barry::Pin
BaseFrame::GetCurrentComboPin()
192 // fetch newly selected device
193 wxString value
= m_device_combo
->GetValue();
194 istringstream
iss(string(value
.utf8_str()).substr(0,8));
200 void BaseFrame::EnableBackButton(Mode
*new_mode
)
202 // create the button - this goes in the bottom FOOTER area
203 // so the height must be fixed to MAIN_HEADER_OFFSET
204 // minus a border of 5px top and bottom
205 wxPoint
pos(10, m_height
- (MAIN_HEADER_OFFSET
- 5));
206 wxSize
size(-1, MAIN_HEADER_OFFSET
- 5 - 5);
208 m_back_button
.reset( new wxButton(this, MainMenu_BackButton
,
209 _W("Main Menu"), pos
, size
) );
212 m_current_mode
= new_mode
;
214 // destroy the device switcher combo box
215 m_device_combo
.reset();
217 // without the device combo, there is no concept of a
218 // "current device" so temporarily disable the USB options
219 m_sysmenu
->Enable(SysMenu_RenameDevice
, false);
220 m_sysmenu
->Enable(SysMenu_ResetDevice
, false);
221 m_sysmenu
->Enable(SysMenu_RescanUsb
, false);
227 void BaseFrame::DisableBackButton()
229 // destroy the back button
230 m_back_button
.reset();
234 m_browse_mode
.reset();
236 // create the device switcher combo again
237 CreateDeviceCombo(wxGetApp().GetGlobalConfig().GetLastDevice());
239 // enable the USB menu options
240 Barry::Pin pin
= GetCurrentComboPin();
241 m_sysmenu
->Enable(SysMenu_RenameDevice
, pin
.Valid());
242 m_sysmenu
->Enable(SysMenu_ResetDevice
, true);
243 m_sysmenu
->Enable(SysMenu_RescanUsb
, true);
245 // reset the current mode to main menu and repaint
246 m_current_mode
= m_main_menu_mode
.get();
249 // if a USB rescan is pending, do it now
250 if( m_rescan_pending
) {
251 wxCommandEvent event
;
256 void BaseFrame::OnSize(wxSizeEvent
&event
)
260 void BaseFrame::OnPaint(wxPaintEvent
&event
)
263 dc
.SetMapMode(wxMM_TEXT
);
265 // paint the background image
266 dc
.DrawBitmap(*m_background
, 0, 0);
268 // paint the header: Barry logo
269 m_barry_logo
->Draw(dc
);
271 // paint the header: NetDirect logo
272 // m_netdirect_logo->Draw(dc);
274 // paint the header: text
275 auto_ptr
<wxFont
> font( wxFont::New(14,
276 wxFONTFAMILY_SWISS
, wxFONTFLAG_ANTIALIASED
,
279 dc
.SetTextForeground( wxColour(0xd2, 0xaf, 0x0b) );
280 dc
.SetTextBackground( wxColour(0, 0, 0, wxALPHA_TRANSPARENT
) );
282 long width
, height
, descent
;
283 wxString header
= _W("Barry Desktop Control Panel");
285 header
= m_current_mode
->GetTitleText();
286 dc
.GetTextExtent(header
, &width
, &height
, &descent
);
287 int x
= (m_width
- width
) / 2;
288 int y
= (MAIN_HEADER_OFFSET
- height
) / 2;
289 dc
.DrawText(header
, x
, y
);
291 // let the mode do its thing
293 m_current_mode
->OnPaint(dc
);
296 void BaseFrame::OnMouseMotion(wxMouseEvent
&event
)
299 m_barry_logo
->HandleMotion(dc
, event
.m_x
, event
.m_y
);
300 // m_netdirect_logo->HandleMotion(dc, event.m_x, event.m_y);
304 m_current_mode
->OnMouseMotion(dc
, event
.m_x
, event
.m_y
);
307 void BaseFrame::OnLeftDown(wxMouseEvent
&event
)
310 m_barry_logo
->HandleDown(dc
, event
.m_x
, event
.m_y
);
311 // m_netdirect_logo->HandleDown(dc, event.m_x, event.m_y);
316 m_current_mode
->OnLeftDown(dc
, event
.m_x
, event
.m_y
);
319 void BaseFrame::OnLeftUp(wxMouseEvent
&event
)
322 m_barry_logo
->HandleUp(dc
, event
.m_x
, event
.m_y
);
323 // m_netdirect_logo->HandleUp(dc, event.m_x, event.m_y);
327 m_current_mode
->OnLeftUp(dc
, event
.m_x
, event
.m_y
);
330 void BaseFrame::OnBackupRestore(wxCommandEvent
&event
)
332 if( m_backup_process
.IsAppRunning() ) {
333 wxMessageBox(_W("The Backup program is already running!"),
334 _W("Backup and Restore"), wxOK
| wxICON_INFORMATION
,
339 if( !m_backup_process
.Run(this, _C("Backup and Restore"), _T("barrybackup")) )
343 void BaseFrame::OnSync(wxCommandEvent
&event
)
345 if( wxGetApp().GetOpenSync().GetAvailable() == 0 ) {
346 wxGetApp().ShowMissingOpenSyncMessage();
351 m_sync_mode
.reset( new SyncMode(this) );
353 catch( std::exception
&e
) {
355 "An error occurred that prevented the loading of Sync\n"
356 "mode. This is most likely because a critical piece\n"
357 "of OpenSync is missing. Check that all required\n"
358 "plugins are installed, and that tools like 'bidentify'\n"
359 "can find your BlackBerry(R) successfully.\n\n"
361 msg
+= wxString(e
.what(), wxConvUTF8
);
362 wxMessageBox(msg
, _W("Sync Mode"), wxOK
| wxICON_ERROR
, this);
366 EnableBackButton(m_sync_mode
.get());
369 void BaseFrame::OnModem(wxCommandEvent
&event
)
371 Barry::Pin pin
= GetCurrentComboPin();
373 ModemDlg::DoModem(this, pin
);
376 wxMessageBox(_W("Please select a device first."),
377 _W("No Device"), wxOK
| wxICON_ERROR
, this);
381 OpenSync::SyncChange change;
383 change.member_id = 1;
384 change.plugin_name = "barry-sync";
385 change.uid = "12341524235234";
386 change.printable_data =
389 " <NodeName>PRODID</NodeName>\n"
390 " <Content>-//OpenSync//NONSGML Barry Contact Record//EN</Content>\n"
393 " <Content>Adame Brandee</Content>\n"
394 " </FormattedName>\n"
396 " <LastName>Brandee</LastName>\n"
397 " <FirstName>Adame</FirstName>\n"
400 " <Content>71 Long St.\n"
401 "Toronto ON Canada\n"
402 "N0N 0N0</Content>\n"
403 " <Type>home</Type>\n"
406 " <Street>71 Long St.</Street>\n"
407 " <City>Toronto</City>\n"
408 " <Region>ON</Region>\n"
409 " <PostalCode>N0N 0N0</PostalCode>\n"
410 " <Country>Canada</Country>\n"
411 " <Type>home</Type>\n"
414 " <Content>+1 (416) 555-7711</Content>\n"
415 " <Type>voice</Type>\n"
416 " <Type>home</Type>\n"
419 " <Content>+1 (416) 955-7117</Content>\n"
420 " <Type>msg</Type>\n"
421 " <Type>cell</Type>\n"
424 " <Content>abrandee@sympatico.ca</Content>\n"
425 " <Type>internet</Type>\n"
426 " <Type>pref</Type>\n"
429 " <Category>Personal</Category>\n"
432 " <Content>Interweb salesman... 24/7</Content>\n"
436 std::vector<OpenSync::SyncChange> changes;
437 changes.push_back(change);
440 change.member_id = 2;
441 change.plugin_name = "evo2-sync";
442 change.uid = "asdfioausdf_1235234as_asdf12341524235234";
443 change.printable_data =
446 " <Content>+1 (416) 955-7117</Content>\n"
447 " <Type>CELL</Type>\n"
451 " <Content>+1 (416) 555-7711</Content>\n"
452 " <Type>HOME</Type>\n"
453 " <Type>VOICE</Type>\n"
457 " <Content>abrandee@sympatico.ca</Content>\n"
458 " <Type>OTHER</Type>\n"
462 " <Content>FALSE</Content>\n"
465 " <Content>20100322T225303Z</Content>\n"
468 " <NodeName>PRODID</NodeName>\n"
469 " <Content>-//OpenSync//NONSGML Barry Contact Record//EN</Content>\n"
472 " <Content>Adam Brandeee</Content>\n"
473 " </FormattedName>\n"
475 " <LastName>Brandeee</LastName>\n"
476 " <FirstName>Adam</FirstName>\n"
479 " <Content>71 Long St.\n"
483 " <Type>home</Type>\n"
486 " <Street>71 Long St.</Street>\n"
487 " <City>Toronto</City>\n"
488 " <Region>ON</Region>\n"
489 " <PostalCode>N0N 0N1</PostalCode>\n"
490 " <Country>Canada</Country>\n"
491 " <Type>home</Type>\n"
494 " <Category>Personal</Category>\n"
497 " <Content>Brandeee, Adam</Content>\n"
501 changes.push_back(change);
504 ConflictDlg::AlwaysMemoryBlock always;
505 ConflictDlg dlg(this, *wxGetApp().GetOpenSync().os22(),
506 "SDAIN", changes, always);
508 wxString msg(dlg.GetCommand().c_str(), wxConvUTF8);
510 msg += always.m_always ? _T("always") : _T("not always");
516 void BaseFrame::OnAppLoader(wxCommandEvent
&event
)
519 OpenSync::SyncChange change;
521 change.member_id = 1;
522 change.plugin_name = "barry-sync";
523 change.uid = "12341524235234";
524 change.printable_data =
528 " <Content>0</Content>\n"
531 " <Content>Subject</Content>\n"
534 " <Content>Bring burnt offering</Content>\n"
537 " <Content>Tent</Content>\n"
540 " <Content>20100506T040000Z</Content>\n"
543 " <Content>20100507T040000Z</Content>\n"
546 " <AlarmAction>AUDIO</AlarmAction>\n"
548 " <Content>20100506T034500Z</Content>\n"
549 " <Value>DATE-TIME</Value>\n"
555 std::vector<OpenSync::SyncChange> changes;
556 changes.push_back(change);
559 change.member_id = 2;
560 change.plugin_name = "evo2-sync";
561 change.uid = "asdfioausdf_1235234as_asdf12341524235234";
562 change.printable_data =
565 " <Content>PUBLISH</Content>\n"
568 " <TimezoneID>/softwarestudio.org/Tzfile/America/Thunder_Bay</TimezoneID>\n"
569 " <Location>America/Thunder_Bay</Location>\n"
571 " <TimezoneName>EST</TimezoneName>\n"
572 " <DateStarted>19701107T010000</DateStarted>\n"
573 " <RecurrenceRule>\n"
574 " <Rule>FREQ=YEARLY</Rule>\n"
575 " <Rule>INTERVAL=1</Rule>\n"
576 " <Rule>BYDAY=2SU</Rule>\n"
577 " <Rule>BYMONTH=11</Rule>\n"
578 " </RecurrenceRule>\n"
579 " <TZOffsetFrom>-0400</TZOffsetFrom>\n"
580 " <TZOffsetTo>-0500</TZOffsetTo>\n"
582 " <DaylightSavings>\n"
583 " <TimezoneName>EDT</TimezoneName>\n"
584 " <DateStarted>19700313T030000</DateStarted>\n"
585 " <RecurrenceRule>\n"
586 " <Rule>FREQ=YEARLY</Rule>\n"
587 " <Rule>INTERVAL=1</Rule>\n"
588 " <Rule>BYDAY=2SU</Rule>\n"
589 " <Rule>BYMONTH=3</Rule>\n"
590 " </RecurrenceRule>\n"
591 " <TZOffsetFrom>-0500</TZOffsetFrom>\n"
592 " <TZOffsetTo>-0400</TZOffsetTo>\n"
593 " </DaylightSavings>\n"
597 " <Content>1</Content>\n"
600 " <Content>Celebration day</Content>\n"
603 " <Content>Tent of</Content>\n"
606 " <Content>20100506T000000</Content>\n"
607 " <TimezoneID>/softwarestudio.org/Tzfile/America/Thunder_Bay</TimezoneID>\n"
610 " <Content>20100507T000000</Content>\n"
611 " <TimezoneID>/softwarestudio.org/Tzfile/America/Thunder_Bay</TimezoneID>\n"
613 " <DateCalendarCreated>\n"
614 " <Content>20100430T214736Z</Content>\n"
615 " </DateCalendarCreated>\n"
617 " <Content>20100430T214736</Content>\n"
620 " <Content>20100430T214927</Content>\n"
623 " <Content>Bring burnt offering</Content>\n"
626 " <Content>PUBLIC</Content>\n"
629 " <Content>OPAQUE</Content>\n"
632 " <AlarmAction>AUDIO</AlarmAction>\n"
634 " <Content>20100506T034500Z</Content>\n"
635 " <Value>DATE-TIME</Value>\n"
642 changes.push_back(change);
645 ConflictDlg::AlwaysMemoryBlock always;
646 ConflictDlg dlg(this, *wxGetApp().GetOpenSync().os22(),
647 "SDAIN", changes, always);
649 wxString msg(dlg.GetCommand().c_str(), wxConvUTF8);
651 msg += always.m_always ? _T("always") : _T("not always");
657 void BaseFrame::OnMigrateDevice(wxCommandEvent
&event
)
661 int i
= Barry::Probe::Find(wxGetApp().GetResults(),
662 GetCurrentComboPin());
664 MigrateDlg
dlg(this, wxGetApp().GetResults(), i
);
668 catch( std::exception
&e
) {
670 "An error occurred during device migration.\n"
671 "This could be due to a low level USB issue\n"
672 "Please make sure your device is plugged in\n"
673 "and not in Desktop Mode. If it is, try replugging\n"
674 "the device, and rescanning the USB bus from the menu.\n"
677 msg
+= wxString(e
.what(), wxConvUTF8
);
678 wxMessageBox(msg
, _W("Migrate Device"), wxOK
| wxICON_ERROR
, this);
683 void BaseFrame::OnBrowseDatabases(wxCommandEvent
&event
)
685 int i
= Barry::Probe::Find(wxGetApp().GetResults(), GetCurrentComboPin());
687 wxMessageBox(_W("There is no device selected in the device list. Please select a device to browse."),
688 _W("Database Browser Mode"), wxOK
| wxICON_ERROR
, this);
693 m_browse_mode
.reset( new BrowseMode(this,
694 wxGetApp().GetResults()[i
]) );
696 catch( std::exception
&e
) {
698 "An error occurred that prevented the loading of Database\n"
699 "Browse mode. This could be due to a low level USB\n"
700 "issue. Please make sure your device is plugged in\n"
701 "and not in Desktop Mode. If it is, try replugging\n"
702 "the device, and rescanning the USB bus from the menu.\n"
705 msg
+= wxString(e
.what(), wxConvUTF8
);
706 wxMessageBox(msg
, _W("Database Browser Mode"), wxOK
| wxICON_ERROR
, this);
710 EnableBackButton(m_browse_mode
.get());
713 void BaseFrame::OnMediaManagement(wxCommandEvent
&event
)
717 void BaseFrame::OnMisc(wxCommandEvent
&event
)
721 void BaseFrame::OnBackButton(wxCommandEvent
&event
)
726 void BaseFrame::OnTermBackupAndRestore(wxProcessEvent
&event
)
728 barryverbose("OnTermBackupAndRestore(): done = "
729 << (!m_backup_process
.IsAppRunning() ? "true" : "false")
730 << ", status = " << m_backup_process
.GetRawAppStatus()
731 << ", exit code = " << m_backup_process
.GetChildExitCode());
732 // only give a warning if the application could not be run...
733 // if there's an error code, and it's been running for longer
734 // than a second or two, then it's a real error code, or a
735 // segfault or something similar.
736 if( !m_backup_process
.IsAppRunning() &&
737 m_backup_process
.GetChildExitCode() &&
738 (time(NULL
) - m_backup_process
.GetStartTime()) < 2 )
740 wxMessageBox(_W("Unable to run barrybackup, or it returned an error. Please make sure it is installed and in your PATH."),
741 _W("Backup and Restore"), wxOK
| wxICON_ERROR
, this);
745 // looks like a successful run... the device name may
746 // have been changed by the BarryBackup GUI, so reprobe
747 // to refresh the names and device list
748 wxCommandEvent event
;
753 void BaseFrame::OnBarryLogoClicked(wxCommandEvent
&event
)
755 PopupMenu(m_sysmenu
.get(), 20, 20);
758 void BaseFrame::OnNetDirectLogoClicked(wxCommandEvent
&event
)
760 // fire up a browser to point to the Barry documentation
762 ::wxLaunchDefaultBrowser(_T("http://netdirect.ca/barry"));
765 void BaseFrame::OnDeviceComboChange(wxCommandEvent
&event
)
767 Barry::Pin pin
= GetCurrentComboPin();
770 if( pin
== wxGetApp().GetGlobalConfig().GetLastDevice() )
774 wxGetApp().GetGlobalConfig().SetLastDevice(pin
);
777 m_sysmenu
->Enable(SysMenu_RenameDevice
, pin
.Valid());
779 // update the main mode's screenshot
780 m_main_menu_mode
->UpdateScreenshot(pin
);
781 if( m_current_mode
== m_main_menu_mode
.get() )
784 // FIXME - if inside a sub menu mode, we need to destroy the mode
785 // class and start fresh
788 void BaseFrame::OnVerboseLogging(wxCommandEvent
&event
)
790 Barry::Verbose( !Barry::IsVerbose() );
791 wxGetApp().GetGlobalConfig().SetVerboseLogging( Barry::IsVerbose() );
795 void BaseFrame::OnRenameDevice(wxCommandEvent
&event
)
797 Barry::Pin pin
= GetCurrentComboPin();
801 // grab the current known name of the device
802 const Barry::Probe::Results
&results
= wxGetApp().GetResults();
803 int index
= Barry::Probe::Find(results
, pin
);
807 wxString
current_name(results
[index
].m_cfgDeviceName
.c_str(), wxConvUTF8
);
808 wxTextEntryDialog
dlg(this,
809 _W("Please enter a name for the current device:"),
811 current_name
, wxTextEntryDialogStyle
);
813 if( dlg
.ShowModal() != wxID_OK
)
814 return; // nothing to do
815 wxString name
= dlg
.GetValue();
816 if( name
== current_name
)
817 return; // nothing to do
819 wxGetApp().SetDeviceName(pin
, string(name
.utf8_str()));
822 CreateDeviceCombo(wxGetApp().GetGlobalConfig().GetLastDevice());
825 void BaseFrame::OnResetDevice(wxCommandEvent
&event
)
827 int i
= Barry::Probe::Find(wxGetApp().GetResults(), GetCurrentComboPin());
829 Usb::Device
dev(wxGetApp().GetResults()[i
].m_dev
);
837 void BaseFrame::OnRescanUsb(wxCommandEvent
&event
)
839 if( m_current_mode
== m_main_menu_mode
.get() ) {
840 std::auto_ptr
<UsbScanSplash
> splash( new UsbScanSplash
);
842 CreateDeviceCombo(wxGetApp().GetGlobalConfig().GetLastDevice());
843 m_rescan_pending
= false;
846 // flag that we need to rescan the next time we return
847 // to the main screen
848 m_rescan_pending
= true;
852 void BaseFrame::OnAbout(wxCommandEvent
&event
)
854 wxAboutDialogInfo info
;
855 info
.SetName(_W("Barry Desktop Control Panel"));
856 info
.SetVersion(_T(BARRY_DESKTOP_VER_STRING
));
857 info
.SetDescription(_W("A Free Software graphical user interface for working with the BlackBerry® smartphone."));
858 info
.SetCopyright(_T("Copyright © 2009-2013, Net Direct Inc."));
859 info
.SetWebSite(_T("http://netdirect.ca/barry"));
861 " This program is free software; you can redistribute it and/or modify\n"
862 " it under the terms of the GNU General Public License as published by\n"
863 " the Free Software Foundation; either version 2 of the License, or\n"
864 " (at your option) any later version.\n"
866 " This program is distributed in the hope that it will be useful,\n"
867 " but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
868 " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
870 " See the GNU General Public License in the COPYING file at the\n"
871 " root directory of this project for more details.\n"));
873 info
.AddDeveloper(_T("Net Direct Inc."));
874 // info.AddDeveloper(_T("Chris Frey <cdfrey@foursquare.net>"));
875 // info.AddDeveloper(_T("See AUTHORS file for detailed"));
876 // info.AddDeveloper(_T("contribution information."));
878 info
.AddArtist(_W("Chris Frey - GUI interface"));
879 info
.AddArtist(_W("Martin Owens - Barry logo"));
880 info
.AddArtist(_W("Tango Desktop Project - Public domain icons"));
885 void BaseFrame::OnExit(wxCommandEvent
&event
)