Barry debian version 0.18.5-1
[barry.git] / desktop / src / barrydesktop.h
bloba7e4808851416fa5418c6c6ae12951ae9899711a
1 ///
2 /// \file barrydesktop.h
3 /// Program entry point for the desktop GUI
4 ///
6 /*
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 #ifndef __BARRYDESKTOP_BARRYDESKTOP_H__
23 #define __BARRYDESKTOP_BARRYDESKTOP_H__
25 #include <wx/wx.h>
26 #include <barry/barry.h>
27 #include <memory>
29 class wxSplashScreen;
30 namespace OpenSync {
31 class APISet;
34 class UsbScanSplash
36 std::auto_ptr<wxSplashScreen> m_splash;
37 public:
38 UsbScanSplash();
39 ~UsbScanSplash();
42 class BarryDesktopApp : public wxApp
44 private:
45 Barry::GlobalConfigFile m_global_config;
46 Barry::Probe::Results m_results;
47 std::auto_ptr<OpenSync::APISet> m_set;
49 public:
50 BarryDesktopApp();
53 // data access
55 Barry::GlobalConfigFile& GetGlobalConfig() { return m_global_config; }
56 const Barry::Probe::Results& GetResults() const { return m_results; }
57 OpenSync::APISet& GetOpenSync() { return *m_set; }
60 // operations
63 void ShowMissingOpenSyncMessage();
65 /// Fills m_results with new data after a brand new scan.
66 /// Does not catch exceptions.
67 void Probe();
69 /// Grabs a screenshot of the given device.
70 /// Can throw exceptions on error.
71 wxBitmap GetScreenshot(const Barry::ProbeResult &device) const;
73 /// Sets the device name for the given device PIN.
74 /// If the PIN exists in m_results, the associated
75 /// m_results entry will be updated with the new device name,
76 /// so the next GetResults() will contain the new name.
77 void SetDeviceName(Barry::Pin pin, const std::string &name);
79 /// Returns device name for the given PIN, but ONLY if the
80 /// device is connected. If you want to read the device
81 /// name of an unconnected device, use DeviceSet or just
82 /// load the config manually with Barry::ConfigFile.
83 std::string GetDeviceName(Barry::Pin pin) const;
86 // overrides
88 virtual bool OnInit();
89 virtual int OnExit();
92 DECLARE_APP(BarryDesktopApp)
94 #endif