Allow client to add new servers

This commit is contained in:
Martin Raiber 2012-05-16 21:58:16 +02:00
parent b0e1fc6dc9
commit a378c4767b
7 changed files with 69 additions and 5 deletions

View File

@ -230,6 +230,11 @@ SStatus Connector::getStatus(void)
{
ret.capa=watoi(it_capa->second);
}
std::map<std::wstring,std::wstring>::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;
}

View File

@ -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<SLogEntry> getLogEntries(void);
static std::vector<SLogLine> getLogdata(int logid, int loglevel);
static bool setPause(bool b_pause);
static bool addNewServer(const std::string &ident);
static bool hasError(void);

View File

@ -3,6 +3,7 @@
#include <wx/stdpaths.h>
#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);
}
}

View File

@ -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();

View File

@ -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);
}
}

View File

@ -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;
};

View File

@ -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;
}