diff --git a/Connector.cpp b/Connector.cpp index 3a5e730..c3c7128 100644 --- a/Connector.cpp +++ b/Connector.cpp @@ -230,6 +230,11 @@ SStatus Connector::getStatus(void) { ret.capa=watoi(it_capa->second); } + std::map::iterator it_new_server=params.find(L"new_ident"); + if(it_new_server!=params.end()) + { + ret.new_server=wnarrow(it_new_server->second); + } } return ret; @@ -340,4 +345,14 @@ bool Connector::setPause(bool b_pause) bool Connector::isBusy(void) { return busy; +} + +bool Connector::addNewServer(const std::string &ident) +{ + std::string d=getResponse("NEW SERVER","ident="+ident); + + if(d!="OK") + return false; + else + return true; } \ No newline at end of file diff --git a/Connector.h b/Connector.h index 313e4bd..fd0d64a 100644 --- a/Connector.h +++ b/Connector.h @@ -37,6 +37,7 @@ struct SStatus wxString pcdone; bool pause; int capa; + std::string new_server; }; struct SLogEntry @@ -64,6 +65,7 @@ public: static std::vector getLogEntries(void); static std::vector getLogdata(int logid, int loglevel); static bool setPause(bool b_pause); + static bool addNewServer(const std::string &ident); static bool hasError(void); diff --git a/TaskBarBaloon.cpp b/TaskBarBaloon.cpp index 8132e7a..ddc9842 100644 --- a/TaskBarBaloon.cpp +++ b/TaskBarBaloon.cpp @@ -3,6 +3,7 @@ #include #include "stringtools.h" #include "main.h" +#include "Connector.h" const int TIMER_BALOON=34; extern MyTimer *timer; @@ -14,8 +15,9 @@ BEGIN_EVENT_TABLE(TaskBarBaloon, wxFrame) EVT_TIMER(TIMER_BALOON,TaskBarBaloon::OnTimerTick) END_EVENT_TABLE() -TaskBarBaloon::TaskBarBaloon(wxString sTitle, wxString sMessage) - : wxFrame(NULL,-1,wxT("no title"),wxDefaultPosition,wxDefaultSize,wxNO_BORDER | wxSTAY_ON_TOP | wxFRAME_SHAPED | wxFRAME_NO_TASKBAR) +TaskBarBaloon::TaskBarBaloon(wxString sTitle, wxString sMessage, std::string new_ident) + : wxFrame(NULL,-1,wxT("no title"),wxDefaultPosition,wxDefaultSize,wxNO_BORDER | wxSTAY_ON_TOP | wxFRAME_SHAPED | wxFRAME_NO_TASKBAR), + new_ident(new_ident) { wxColour bgColour(255,255,231); // yellow BG this->SetBackgroundColour(bgColour); @@ -152,5 +154,12 @@ void update_urbackup(void) void TaskBarBaloon::OnClick(wxMouseEvent & event) { this->Show(false); - update_urbackup(); + if(new_ident.empty()) + { + update_urbackup(); + } + else + { + Connector::addNewServer(new_ident); + } } \ No newline at end of file diff --git a/TaskBarBaloon.h b/TaskBarBaloon.h index e6fe758..e04108c 100644 --- a/TaskBarBaloon.h +++ b/TaskBarBaloon.h @@ -5,7 +5,7 @@ class TaskBarBaloon : public wxFrame { public: - TaskBarBaloon(wxString sTitle, wxString sMessage); + TaskBarBaloon(wxString sTitle, wxString sMessage, std::string new_ident=""); virtual ~TaskBarBaloon() { delete timer; } /** painting bg */ @@ -21,6 +21,7 @@ class TaskBarBaloon : public wxFrame void showBaloon(unsigned int iTimeout); private: wxTimer * timer; + std::string new_ident; DECLARE_EVENT_TABLE(); diff --git a/TrayIcon.cpp b/TrayIcon.cpp index 2acf6d8..7cc06d8 100644 --- a/TrayIcon.cpp +++ b/TrayIcon.cpp @@ -53,6 +53,7 @@ extern wxBitmapType ico_type; TrayIcon::TrayIcon(void) : wxTaskBarIcon() { + balloon_action=0; #ifdef wxUSE_TASKBARICON_BALLOONS Connect(wxEVT_TASKBAR_BALLOON_CLICK, (wxObjectEventFunction)&TrayIcon::OnBalloonClick, NULL, this); #endif @@ -192,10 +193,27 @@ wxMenu* TrayIcon::CreatePopupMenu(void) return mnu; } +void TrayIcon::BalloonActionNewServer(const std::string &ident) +{ + balloon_action=1; + new_ident=ident; +} + +void TrayIcon::BalloonActionUpgrade(void) +{ + balloon_action=0; +} void update_urbackup(void); void TrayIcon::OnBalloonClick(wxCommandEvent &evt) { - update_urbackup(); + if(balloon_action==0) + { + update_urbackup(); + } + else + { + Connector::addNewServer(new_ident); + } } \ No newline at end of file diff --git a/TrayIcon.h b/TrayIcon.h index 0b16ef8..ed02d2c 100644 --- a/TrayIcon.h +++ b/TrayIcon.h @@ -27,4 +27,11 @@ public: wxMenu* CreatePopupMenu(void); void OnPopupClick(wxCommandEvent &evt); void OnBalloonClick(wxCommandEvent &evt); + void BalloonActionUpgrade(void); + void BalloonActionNewServer(const std::string &ident); + + +private: + int balloon_action; + std::string new_ident; }; \ No newline at end of file diff --git a/main.cpp b/main.cpp index 965aac5..76b9f90 100644 --- a/main.cpp +++ b/main.cpp @@ -216,6 +216,7 @@ void MyTimer::Notify() TaskBarBaloon *tbb=new TaskBarBaloon(_("UrBackup: Update verfügbar"), _("Eine neue Version von UrBackup ist verfügbar. Klicken Sie hier um diese zu installieren")); tbb->showBaloon(80000); #else + tray->BalloonActionUpgrade(); tray->ShowBalloon(_("UrBackup: Update verfügbar"), _("Eine neue Version von UrBackup ist verfügbar. Klicken Sie hier um diese zu installieren"), 30000, wxICON_INFORMATION); displayed_update_info=true; #endif @@ -365,6 +366,17 @@ void MyTimer::Notify() } } + if(!status.new_server.empty()) + { +#ifndef wxUSE_TASKBARICON_BALLOONS + TaskBarBaloon *tbb=new TaskBarBaloon(_("UrBackup: Neuer Server"), _("Ein neuer Backup Server wurde gefunden. Hier klicken um diesen zu benutzen"), status.new_server); + tbb->showBaloon(80000); +#else + tray->BalloonActionNewServer(status.new_server); + tray->ShowBalloon(_("UrBackup: Neuer Server"), _("Ein neuer Backup Server wurde gefunden. Hier klicken um diesen zu benutzen"), 80000, wxICON_INFORMATION); +#endif + } + working=false; }