Initial commit

This commit is contained in:
Martin Raiber 2011-01-16 20:15:29 +01:00
commit dbbf397606
56 changed files with 9861 additions and 0 deletions

52
.gitignore vendored Normal file
View File

@ -0,0 +1,52 @@
backup-bad.png
backup-bad.psb
backup-bad32.ico
backup-bad32.png
backup-ok-big.ico
backup-ok.png
backup-ok.psb
backup-ok32.png
BaseImage.psb
BaseImage_ok.psb
comp.uri
curr_version.txt
data/*
data_dbg/*
data_x64/*
Debug/*
Installer/*
ipch/*
KillProc/Debug/*
KillProc/ipch/*
*.ncb
*.sdf
*.suo
*.vcproj*
*.vcxproj.user
KillProc/Release/*
KillProc/x64/*
logos/*
messages.mo
pw.txt
release.bat
Release/*
sha256deep.exe
signer/*
test
tool2.exe
update_data.bat
update_data_dbg.bat
update_sign.bat
urbackup - Kopie.nsi
UrBackup Client*.exe
urbackup/*
UrBackupClientGUI.aps
UrBackupUpdate.exe
UrBackupUpdate.sig
VCRedist/*
wx64/*
wx86/*
x64/*
UrBackupClientGUI.exe
UrBackupClientGUI.opensdf

91
ConfigPath.cpp Normal file
View File

@ -0,0 +1,91 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "ConfigPath.h"
#define CP_ID_OK 100
ConfigPath::ConfigPath(void)
: wxFrame(NULL, wxID_ANY, _("Pfade hinzufügen und entfernen"), wxDefaultPosition, wxSize(500, 600))
{
SetIcon(wxIcon(wxT("backup-ok-big.ico"), wxBITMAP_TYPE_ICO));
wxPanel *panel = new wxPanel(this, wxID_ANY);
listbox=new wxListBox(panel, wxID_ANY, wxPoint(17,5), wxSize(450,500));
wxButton *btnOk=new wxButton(panel, wxID_ANY, _("Ok"), wxPoint(17,517), wxSize(60,30) );
wxButton *btnAbort=new wxButton(panel, wxID_ANY, _("Abbrechen"), wxPoint(85,517), wxSize(70,30) );
wxButton *btnNew=new wxButton(panel, wxID_ANY, _("Neuer Pfad"), wxPoint(286,517), wxSize(80,30) );
wxButton *btnDel=new wxButton(panel, wxID_ANY, _("Pfad entfernen"), wxPoint(377,517), wxSize(90,30) );
btnOk->Connect(wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&ConfigPath::OnClickOk, NULL, this);
btnAbort->Connect(wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&ConfigPath::OnClickAbort, NULL, this);
btnNew->Connect(wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&ConfigPath::OnClickNew, NULL, this);
btnDel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&ConfigPath::OnClickDel, NULL, this);
dirs=Connector::getSharedPaths();
if(Connector::hasError())
{
wxMessageBox(_("Ein Fehler ist aufgetreten. Backups werden momentan nicht durchgeführt."), wxT("UrBackup"), wxOK|wxICON_ERROR);
Hide();
Close();
}
for(size_t i=0;i<dirs.size();++i)
{
listbox->Append(dirs[i].path);
}
Centre();
Show(true);
}
void ConfigPath::OnClickOk(wxCommandEvent &evt)
{
Connector::saveSharedPaths(dirs);
Close();
}
void ConfigPath::OnClickAbort(wxCommandEvent &evt)
{
Close();
}
void ConfigPath::OnClickNew(wxCommandEvent &evt)
{
wxDirDialog ed(this, _("Bitte Verzeichnis das gesichert werden soll auswählen"), wxEmptyString, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
int rc=ed.ShowModal();
if(rc==wxID_OK)
{
listbox->Append(ed.GetPath() );
SBackupDir ad;
ad.path=ed.GetPath();
dirs.push_back(ad);
}
}
void ConfigPath::OnClickDel(wxCommandEvent &evt)
{
int sel=listbox->GetSelection();
if(sel>=0)
{
listbox->Delete(sel);
dirs.erase(dirs.begin()+sel);
}
}

38
ConfigPath.h Normal file
View File

@ -0,0 +1,38 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include <wx/wx.h>
#include <wx/listctrl.h>
#include "Connector.h"
class ConfigPath : public wxFrame
{
public:
ConfigPath(void);
void OnClickOk(wxCommandEvent &evt);
void OnClickAbort(wxCommandEvent &evt);
void OnClickNew(wxCommandEvent &evt);
void OnClickDel(wxCommandEvent &evt);
private:
std::vector<SBackupDir> dirs;
wxListBox *listbox;
};

297
Connector.cpp Normal file
View File

@ -0,0 +1,297 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "Connector.h"
#include "tcpstack.h"
#include "stringtools.h"
#include <wx/socket.h>
#include "escape.h"
std::string Connector::pw;
bool Connector::error=false;
const size_t conn_retries=4;
bool Connector::busy=false;
std::string Connector::getResponse(const std::string &cmd, const std::string &args)
{
busy=true;
error=false;
if(pw.empty())
{
pw=getFile("pw.txt");
}
wxSocketClient client(wxSOCKET_BLOCK);
wxIPV4address addr;
addr.Hostname(wxT("127.0.0.1"));
addr.Service(35623);
if(!client.Connect(addr,false))
{
for(size_t k=0;k<conn_retries;++k)
{
if(client.WaitOnConnect(0,500))
{
break;
}
wxTheApp->SafeYield(NULL, false);
}
}
if(!client.IsConnected())
{
wxSocketError err=client.LastError();
error=true;
busy=false;
return "";
}
std::string t_args;
if(!args.empty())
t_args="&"+args;
else
t_args=args;
CTCPStack tcpstack;
tcpstack.Send(&client, cmd+"#pw="+pw+t_args);
char *resp=NULL;
char buffer[1024];
size_t packetsize;
while(resp==NULL)
{
bool conn=false;
for(size_t k=0;k<conn_retries;++k)
{
if(client.WaitForRead(0,500))
{
conn=true;
break;
}
wxTheApp->SafeYield(NULL, false);
if(client.Error())
break;
}
if(!conn)
{
error=true;
busy=false;
return "";
}
client.Read(buffer, 1024);
if(client.Error())
{
error=true;
busy=false;
return "";
}
tcpstack.AddData(buffer, client.GetLastIOSize() );
resp=tcpstack.getPacket(&packetsize);
if(packetsize==0)
{
client.Close();
busy=false;
return "";
}
}
std::string ret;
ret.resize(packetsize);
memcpy(&ret[0], resp, packetsize);
delete resp;
client.Close();
busy=false;
return ret;
}
bool Connector::hasError(void)
{
return error;
}
std::vector<SBackupDir> Connector::getSharedPaths(void)
{
std::vector<SBackupDir> ret;
std::string d=getResponse("GET BACKUP DIRS","");
int lc=linecount(d);
for(int i=0;i<lc;i+=2)
{
SBackupDir bd;
bd.id=atoi(getline(i, d).c_str() );
bd.path=wxString::FromUTF8(getline(i+1, d).c_str() );
ret.push_back( bd );
}
return ret;
}
bool Connector::saveSharedPaths(const std::vector<SBackupDir> &res)
{
std::string args;
for(size_t i=0;i<res.size();++i)
{
if(i!=0)
args+="&";
args+="dir_"+nconvert(i)+"="+(std::string)res[i].path.ToUTF8().data();
}
std::string d=getResponse("SAVE BACKUP DIRS", args);
if(d!="OK")
return false;
else
return true;
}
SStatus Connector::getStatus(void)
{
std::string d=getResponse("STATUS","");
std::vector<std::string> toks;
Tokenize(d, toks, "#");
SStatus ret;
ret.pause=false;
if(toks.size()>0)
ret.lastbackupdate=wxString::FromUTF8(toks[0].c_str() );
if(toks.size()>1)
ret.status=wxString::FromUTF8(toks[1].c_str() );
if(toks.size()>2)
ret.pcdone=wxString::FromUTF8(toks[2].c_str() );
if(toks.size()>3)
{
if(toks[3]=="P")
ret.pause=true;
else if(toks[3]=="NP")
ret.pause=false;
}
return ret;
}
unsigned int Connector::getIncrUpdateIntervall(void)
{
std::string d=getResponse("GET INCRINTERVALL","");
return atoi(d.c_str());
}
int Connector::startBackup(bool full)
{
std::string s;
if(full)
s="START BACKUP FULL";
else
s="START BACKUP INCR";
std::string d=getResponse(s,"");
if(d=="RUNNING")
return 2;
else if(d!="OK")
return 0;
else
return 1;
}
int Connector::startImage(bool full)
{
std::string s;
if(full)
s="START IMAGE FULL";
else
s="START IMAGE INCR";
std::string d=getResponse(s,"");
if(d=="RUNNING")
return 2;
else if(d!="OK")
return 0;
else
return 1;
}
bool Connector::updateSettings(const std::string &ndata)
{
std::string data=ndata;
escapeClientMessage(data);
std::string d=getResponse("UPDATE SETTINGS "+data,"");
if(d!="OK")
return false;
else
return true;
}
std::vector<SLogEntry> Connector::getLogEntries(void)
{
std::string d=getResponse("GET LOGPOINTS","");
int lc=linecount(d);
std::vector<SLogEntry> ret;
for(int i=0;i<lc;++i)
{
std::string l=getline(i, d);
if(l.empty())continue;
SLogEntry le;
le.logid=atoi(getuntil("-", l).c_str() );
std::string lt=getafter("-", l);
le.logtime=wxString::FromUTF8(lt.c_str());
ret.push_back(le);
}
return ret;
}
std::vector<SLogLine> Connector::getLogdata(int logid, int loglevel)
{
std::string d=getResponse("GET LOGDATA","logid="+nconvert(logid)+"&loglevel="+nconvert(loglevel));
std::vector<std::string> lines;
TokenizeMail(d, lines, "\n");
std::vector<SLogLine> ret;
for(size_t i=0;i<lines.size();++i)
{
std::string l=lines[i];
if(l.empty())continue;
SLogLine ll;
ll.loglevel=atoi(getuntil("-", l).c_str());
ll.msg=wxString::FromUTF8(getafter("-", l).c_str());
ret.push_back(ll);
}
return ret;
}
bool Connector::setPause(bool b_pause)
{
std::string data=b_pause?"true":"false";
std::string d=getResponse("PAUSE "+data,"");
if(d!="OK")
return false;
else
return true;
}
bool Connector::isBusy(void)
{
return busy;
}

77
Connector.h Normal file
View File

@ -0,0 +1,77 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#ifndef CONNECTOR_H
#define CONNECTOR_H
#include <wx/wx.h>
#include <string>
#include <vector>
struct SBackupDir
{
wxString path;
int id;
};
struct SStatus
{
wxString lastbackupdate;
wxString status;
wxString pcdone;
bool pause;
};
struct SLogEntry
{
int logid;
wxString logtime;
};
struct SLogLine
{
int loglevel;
wxString msg;
};
class Connector
{
public:
static std::vector<SBackupDir> getSharedPaths(void);
static bool saveSharedPaths(const std::vector<SBackupDir> &res);
static SStatus getStatus(void);
static unsigned int getIncrUpdateIntervall(void);
static int startBackup(bool full);
static int startImage(bool full);
static bool updateSettings(const std::string &sdata);
static std::vector<SLogEntry> getLogEntries(void);
static std::vector<SLogLine> getLogdata(int logid, int loglevel);
static bool setPause(bool b_pause);
static bool hasError(void);
static bool isBusy(void);
private:
static std::string getResponse(const std::string &cmd, const std::string &args);
static std::string pw;
static bool error;
static bool busy;
};
#endif //CONNECTOR_H

113
FileSettingsReader.cpp Normal file
View File

@ -0,0 +1,113 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "utf8/utf8.h"
#include "stringtools.h"
#include "FileSettingsReader.h"
std::wstring ConvertToUnicode(const std::string &input)
{
std::wstring ret;
try
{
if(sizeof(wchar_t)==2)
utf8::utf8to16(input.begin(), input.end(), back_inserter(ret));
else
utf8::utf8to32(input.begin(), input.end(), back_inserter(ret));
}
catch(...){}
return ret;
}
std::string ConvertToUTF8(const std::wstring &input)
{
std::string ret;
try
{
if(sizeof(wchar_t)==2 )
utf8::utf16to8(input.begin(), input.end(), back_inserter(ret));
else
utf8::utf32to8(input.begin(), input.end(), back_inserter(ret));
}
catch(...){}
return ret;
}
CFileSettingsReader::CFileSettingsReader(std::string pFile)
{
std::string pData=getFile(pFile);
int num_lines=linecount(pData);
for(int i=0;i<num_lines;++i)
{
std::string line=getline(i,pData);
if(line.size()<2 || line[0]=='#' )
continue;
std::string key=getuntil("=",line);
std::string value;
if(key=="")
value=line;
else
{
line.erase(0,key.size()+1);
value=line;
}
mSettingsMap.insert(std::pair<std::wstring,std::wstring>(ConvertToUnicode(key), ConvertToUnicode(value)) );
}
}
bool CFileSettingsReader::getValue(std::string key, std::string *value)
{
std::wstring s_value;
bool b=getValue( widen(key), &s_value);
if(b==true)
{
std::string nvalue=wnarrow(s_value);
*value=nvalue;
return true;
}
return false;
}
bool CFileSettingsReader::getValue(std::wstring key, std::wstring *value)
{
std::map<std::wstring,std::wstring>::iterator i=mSettingsMap.find(key);
if( i!=mSettingsMap.end() )
{
*value=i->second;
return true;
}
return false;
}
std::vector<std::wstring> CFileSettingsReader::getKeys(void)
{
std::vector<std::wstring> ret;
for(std::map<std::wstring,std::wstring>::iterator i=mSettingsMap.begin();i!=mSettingsMap.end();++i)
{
ret.push_back(i->first);
}
return ret;
}

35
FileSettingsReader.h Normal file
View File

@ -0,0 +1,35 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include <string>
#include <map>
class CFileSettingsReader
{
public:
CFileSettingsReader(std::string pFile);
virtual bool getValue(std::string key, std::string *value);
virtual bool getValue(std::wstring key, std::wstring *value);
std::vector<std::wstring> getKeys(void);
private:
std::map<std::wstring,std::wstring> mSettingsMap;
};

29
Info.cpp Normal file
View File

@ -0,0 +1,29 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "Info.h"
Info::Info(wxWindow* parent) : GUIInfo(parent)
{
Show(true);
}
void Info::OnOKClick( wxCommandEvent& event )
{
Close();
}

28
Info.h Normal file
View File

@ -0,0 +1,28 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "gui/GUI.h"
class Info : public GUIInfo
{
public:
Info(wxWindow* parent);
protected:
void OnOKClick( wxCommandEvent& event );
};

26
KillProc/KillProc.sln Normal file
View File

@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KillProc", "KillProc.vcxproj", "{CFBD2BA6-E5D2-4CB9-A72F-08DEC7E2BF36}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CFBD2BA6-E5D2-4CB9-A72F-08DEC7E2BF36}.Debug|Win32.ActiveCfg = Debug|Win32
{CFBD2BA6-E5D2-4CB9-A72F-08DEC7E2BF36}.Debug|Win32.Build.0 = Debug|Win32
{CFBD2BA6-E5D2-4CB9-A72F-08DEC7E2BF36}.Debug|x64.ActiveCfg = Debug|x64
{CFBD2BA6-E5D2-4CB9-A72F-08DEC7E2BF36}.Debug|x64.Build.0 = Debug|x64
{CFBD2BA6-E5D2-4CB9-A72F-08DEC7E2BF36}.Release|Win32.ActiveCfg = Release|Win32
{CFBD2BA6-E5D2-4CB9-A72F-08DEC7E2BF36}.Release|Win32.Build.0 = Release|Win32
{CFBD2BA6-E5D2-4CB9-A72F-08DEC7E2BF36}.Release|x64.ActiveCfg = Release|x64
{CFBD2BA6-E5D2-4CB9-A72F-08DEC7E2BF36}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

179
KillProc/KillProc.vcxproj Normal file
View File

@ -0,0 +1,179 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{CFBD2BA6-E5D2-4CB9-A72F-08DEC7E2BF36}</ProjectGuid>
<RootNamespace>KillProc</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>NotSet</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>NotSet</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="getpid.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Quelldateien">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Headerdateien">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Ressourcendateien">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="getpid.h">
<Filter>Headerdateien</Filter>
</ClInclude>
</ItemGroup>
</Project>

161
KillProc/getpid.h Normal file
View File

@ -0,0 +1,161 @@
typedef struct _PROCESS_MEMORY_COUNTERS
{
DWORD cb;
DWORD PageFaultCount;
SIZE_T PeakWorkingSetSize;
SIZE_T WorkingSetSize;
SIZE_T QuotaPeakPagedPoolUsage;
SIZE_T QuotaPagedPoolUsage;
SIZE_T QuotaPeakNonPagedPoolUsage;
SIZE_T QuotaNonPagedPoolUsage;
SIZE_T PagefileUsage;
SIZE_T PeakPagefileUsage;
} PROCESS_MEMORY_COUNTERS, *PPROCESS_MEMORY_COUNTERS;
typedef BOOL (WINAPI *LPPMI) (HANDLE, PPROCESS_MEMORY_COUNTERS, DWORD);
void Debug(char *dbg)
{
}
int GetMemoryStatus(HANDLE hProc)
{
HINSTANCE hDll;
PROCESS_MEMORY_COUNTERS pmc;
pmc.cb = sizeof(PROCESS_MEMORY_COUNTERS);
hDll = LoadLibrary( TEXT("PSAPI.DLL") );
if(hDll)
{
LPPMI GetProcessMemoryInfo = (LPPMI)GetProcAddress(hDll, "GetProcessMemoryInfo");
if(GetProcessMemoryInfo)
{
if(hProc)
{
GetProcessMemoryInfo(hProc, &pmc, pmc.cb);
}
else
Debug("NOPE: OpenProcess");
}
else
Debug("NOPE: GetProcAddress");
FreeLibrary(hDll);
}
else
Debug("NOPE: LoadLibrary");
return (int)pmc.WorkingSetSize;
}
DWORD getpid(const char* name)
{
// Win/NT or 2000 or XP
// Load library and get the procedures explicitly. We do
// this so that we don't have to worry about modules using
// this code failing to load under Windows 9x, because
// it can't resolve references to the PSAPI.DLL.
HINSTANCE hInstLib;
int iLen,iLenP,indx;
char szName[MAX_PATH],szToTermUpper[MAX_PATH];
BOOL bResult;
DWORD aiPID[1000],iCb=1000,iNumProc;
DWORD iCbneeded,i;
HANDLE hProc;
HMODULE hMod;
DWORD retPID=0;
// PSAPI Function Pointers.
BOOL (WINAPI *lpfEnumProcesses)( DWORD *, DWORD cb, DWORD * );
BOOL (WINAPI *lpfEnumProcessModules)( HANDLE, HMODULE *,
DWORD, LPDWORD );
DWORD (WINAPI *lpfGetModuleBaseName)( HANDLE, HMODULE,
LPTSTR, DWORD );
// Transfer Process name into "szToTermUpper" and
// convert it to upper case
iLenP=strlen(name);
if(iLenP<1 || iLenP>MAX_PATH) return 632;
for(indx=0;indx<iLenP;indx++)
szToTermUpper[indx]=toupper(name[indx]);
szToTermUpper[iLenP]=0;
hInstLib = LoadLibraryA("PSAPI.DLL");
if(hInstLib == NULL)
return 605;
// Get procedure addresses.
lpfEnumProcesses = (BOOL(WINAPI *)(DWORD *,DWORD,DWORD*))
GetProcAddress( hInstLib, "EnumProcesses" ) ;
lpfEnumProcessModules = (BOOL(WINAPI *)(HANDLE, HMODULE *,
DWORD, LPDWORD)) GetProcAddress( hInstLib,
"EnumProcessModules" ) ;
lpfGetModuleBaseName =(DWORD (WINAPI *)(HANDLE, HMODULE,
LPTSTR, DWORD )) GetProcAddress( hInstLib,
"GetModuleBaseNameA" ) ;
if(lpfEnumProcesses == NULL ||
lpfEnumProcessModules == NULL ||
lpfGetModuleBaseName == NULL)
{
FreeLibrary(hInstLib);
return 700;
}
bResult=lpfEnumProcesses(aiPID,iCb,&iCbneeded);
if(!bResult)
{
// Unable to get process list, EnumProcesses failed
FreeLibrary(hInstLib);
return 701;
}
// How many processes are there?
int maxmem=0;
iNumProc=iCbneeded/sizeof(DWORD);
for(i=0;i<iNumProc;i++)
{
// Get the (module) name for this process
strcpy(szName,"Unknown");
// First, get a handle to the process
hProc=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,FALSE,
aiPID[i]);
// Now, get the process name
if(hProc)
{
if(lpfEnumProcessModules(hProc,&hMod,sizeof(hMod),&iCbneeded) )
{
lpfGetModuleBaseName(hProc,hMod,szName,MAX_PATH);
}
}
else
continue;
// We will match regardless of lower or upper case
if(strcmp(strupr(szName),szToTermUpper)==0)
{
int mem=GetMemoryStatus(hProc);
if(mem>maxmem)
{
retPID=aiPID[i];
maxmem=mem;
}
}
CloseHandle(hProc);
}
return retPID;
}

22
KillProc/main.cpp Normal file
View File

@ -0,0 +1,22 @@
#include <windows.h>
#include "getpid.h"
int main(int argc, char *argv[])
{
if(argc==1)
return 2;
DWORD pid=getpid(argv[1] );
HANDLE p=OpenProcess(PROCESS_TERMINATE, FALSE, pid);
if(p)
{
TerminateProcess(p,0);
CloseHandle(p);
return 1;
}
else
{
return 0;
}
}

76
Logs.cpp Normal file
View File

@ -0,0 +1,76 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "Logs.h"
Logs::Logs(wxWindow* parent) : GUILogfiles(parent)
{
SetIcon(wxIcon(wxT("backup-ok-big.ico"), wxBITMAP_TYPE_ICO));
logentries=Connector::getLogEntries();
if(Connector::hasError())
{
wxMessageBox(_("Ein Fehler ist aufgetreten. Backups werden momentan nicht durchgeführt."), wxT("UrBackup"), wxOK|wxICON_ERROR);
Hide();
Close();
}
for(size_t i=0;i<logentries.size();++i)
{
m_listBox1->Append(logentries[i].logtime);
}
Show(true);
}
void Logs::OnLogEntrySelect( wxCommandEvent& event )
{
int sel=m_listBox1->GetSelection();
if(sel>=0)
{
std::vector<SLogLine> data=Connector::getLogdata(logentries[sel].logid, m_choice1->GetSelection());
wxString msg;
for(size_t i=0;i<data.size();++i)
{
msg+=data[i].msg;
msg+=wxT("\r\n");
}
m_textCtrl3->SetValue(msg);
}
}
void Logs::OnLoglevelChange( wxCommandEvent& event )
{
int sel=m_listBox1->GetSelection();
if(sel>=0)
{
std::vector<SLogLine> data=Connector::getLogdata(logentries[sel].logid, m_choice1->GetSelection());
wxString msg;
for(size_t i=0;i<data.size();++i)
{
msg+=data[i].msg;
msg+=wxT("\r\n");
}
m_textCtrl3->SetValue(msg);
}
}
void Logs::OnExitClick( wxCommandEvent& event )
{
Close();
}

34
Logs.h Normal file
View File

@ -0,0 +1,34 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "gui/GUI.h"
#include "Connector.h"
class Logs : public GUILogfiles
{
public:
Logs(wxWindow* parent);
protected:
void OnLogEntrySelect( wxCommandEvent& event );
void OnLoglevelChange( wxCommandEvent& event );
void OnExitClick( wxCommandEvent& event );
private:
std::vector<SLogEntry> logentries;
};

327
Settings.cpp Normal file
View File

@ -0,0 +1,327 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "Settings.h"
#include "stringtools.h"
std::string ConvertToUTF8(const std::wstring &input);
Settings::Settings(wxWindow* parent) : GUISettings(parent)
{
SetIcon(wxIcon(wxT("backup-ok-big.ico"), wxBITMAP_TYPE_ICO));
settings=new CFileSettingsReader("urbackup/data/settings.cfg");
std::wstring t;
if(settings->getValue(L"update_freq_incr", &t))
{
m_textCtrl1->SetValue(wxString(convert(watoi(t)/60/60).c_str()));
}
else
{
m_textCtrl1->SetValue(wxT("1"));
}
if(settings->getValue(L"update_freq_full", &t))
{
m_textCtrl2->SetValue(wxString(convert(watoi(t)/24/60/60).c_str()));
}
else
{
m_textCtrl1->SetValue(wxT("30"));
}
if(settings->getValue(L"update_freq_image_full", &t))
{
if(watoi(t)>0)
{
m_textCtrl22->SetValue(wxString(convert(watoi(t)/24/60/60).c_str()));
m_checkBox1->SetValue(true);
}
else
{
if(settings->getValue(L"update_freq_image_full_orig", &t))
{
m_textCtrl22->SetValue(wxString(convert(watoi(t)/24/60/60).c_str()));
}
m_textCtrl21->Enable(false);
m_textCtrl22->Enable(false);
m_checkBox1->SetValue(false);
}
}
else
{
m_textCtrl21->SetValue(wxT("60"));
m_checkBox1->SetValue(true);
}
if(settings->getValue(L"update_freq_image_incr", &t))
{
m_textCtrl21->SetValue(wxString(convert(watoi(t)/24/60/60).c_str()));
}
else
{
m_textCtrl21->SetValue(wxT("7"));
}
if(settings->getValue(L"max_file_incr", &t))
{
m_textCtrl131->SetValue(wxString(convert(watoi(t)).c_str()));
}
else
{
m_textCtrl131->SetValue(wxT("100"));
}
if(settings->getValue(L"min_file_incr", &t))
{
m_textCtrl13->SetValue(wxString(convert(watoi(t)).c_str()));
}
else
{
m_textCtrl13->SetValue(wxT("40"));
}
if(settings->getValue(L"max_file_full", &t))
{
m_textCtrl133->SetValue(wxString(convert(watoi(t)).c_str()));
}
else
{
m_textCtrl133->SetValue(wxT("10"));
}
if(settings->getValue(L"min_file_full", &t))
{
m_textCtrl132->SetValue(wxString(convert(watoi(t)).c_str()));
}
else
{
m_textCtrl132->SetValue(wxT("2"));
}
if(settings->getValue(L"min_image_incr", &t))
{
m_textCtrl134->SetValue(wxString(convert(watoi(t)).c_str()));
}
else
{
m_textCtrl134->SetValue(wxT("4"));
}
if(settings->getValue(L"max_image_incr", &t))
{
m_textCtrl135->SetValue(wxString(convert(watoi(t)).c_str()));
}
else
{
m_textCtrl135->SetValue(wxT("30"));
}
if(settings->getValue(L"min_image_full", &t))
{
m_textCtrl136->SetValue(wxString(convert(watoi(t)).c_str()));
}
else
{
m_textCtrl136->SetValue(wxT("2"));
}
if(settings->getValue(L"max_image_full", &t))
{
m_textCtrl137->SetValue(wxString(convert(watoi(t)).c_str()));
}
else
{
m_textCtrl137->SetValue(wxT("5"));
}
Show(true);
}
Settings::~Settings(void)
{
delete settings;
}
void Settings::OnOkClick( wxCommandEvent& event )
{
wxString update_freq_incr=m_textCtrl1->GetValue();
wxString update_freq_full=m_textCtrl2->GetValue();
wxString update_freq_image_full=m_textCtrl22->GetValue();
wxString update_freq_image_incr=m_textCtrl21->GetValue();
wxString max_file_incr=m_textCtrl131->GetValue();
wxString min_file_incr=m_textCtrl13->GetValue();
wxString max_file_full=m_textCtrl133->GetValue();
wxString min_file_full=m_textCtrl132->GetValue();
wxString min_image_incr=m_textCtrl135->GetValue();
wxString max_image_incr=m_textCtrl134->GetValue();
wxString min_image_full=m_textCtrl136->GetValue();
wxString max_image_full=m_textCtrl137->GetValue();
long l_update_freq_incr,l_update_freq_full;
long l_update_freq_image_full, l_update_freq_image_full_orig, l_update_freq_image_incr;
long l_max_file_incr, l_min_file_incr;
long l_max_file_full, l_min_file_full;
long l_min_image_incr, l_max_image_incr;
long l_min_image_full, l_max_image_full;
if(update_freq_incr.ToLong(&l_update_freq_incr)==false )
{
wxMessageBox( _("Die inkrementelle Backupzeit ist keine Zahl"), wxT("UrBackup"), wxICON_ERROR);
m_textCtrl1->SetFocus();
return;
}
if(update_freq_full.ToLong(&l_update_freq_full)==false )
{
wxMessageBox( _("Die volle Backupzeit ist keine Zahl"), wxT("UrBackup"), wxICON_ERROR);
m_textCtrl2->SetFocus();
return;
}
if(update_freq_image_full.ToLong(&l_update_freq_image_full)==false )
{
wxMessageBox( _("Die volle Imagebackupzeit ist keine Zahl"), wxT("UrBackup"), wxICON_ERROR);
m_textCtrl22->SetFocus();
return;
}
if(update_freq_image_incr.ToLong(&l_update_freq_image_incr)==false )
{
wxMessageBox( _("Die inkrementelle Imagebackupzeit ist keine Zahl"), wxT("UrBackup"), wxICON_ERROR);
m_textCtrl21->SetFocus();
return;
}
if(max_file_incr.ToLong(&l_max_file_incr)==false )
{
wxMessageBox( _("Die maximale Anzahl an inkrementellen Backups ist keine Zahl"), wxT("UrBackup"), wxICON_ERROR);
m_textCtrl131->SetFocus();
return;
}
if(min_file_incr.ToLong(&l_min_file_incr)==false )
{
wxMessageBox( _("Die minimale Anzahl an inkrementellen Backups ist keine Zahl"), wxT("UrBackup"), wxICON_ERROR);
m_textCtrl13->SetFocus();
return;
}
if(max_file_full.ToLong(&l_max_file_full)==false )
{
wxMessageBox( _("Die maximale Anzahl an vollen Backups ist keine Zahl"), wxT("UrBackup"), wxICON_ERROR);
m_textCtrl133->SetFocus();
return;
}
if(min_file_full.ToLong(&l_min_file_full)==false )
{
wxMessageBox( _("Die minimale Anzahl an vollen Backups ist keine Zahl"), wxT("UrBackup"), wxICON_ERROR);
m_textCtrl132->SetFocus();
return;
}
if(min_image_incr.ToLong(&l_min_image_incr)==false )
{
wxMessageBox( _("Die minimale Anzahl an inkrementellen Image-Backups ist keine Zahl"), wxT("UrBackup"), wxICON_ERROR);
m_textCtrl134->SetFocus();
return;
}
if(max_image_incr.ToLong(&l_max_image_incr)==false )
{
wxMessageBox( _("Die maximale Anzahl an inkrementellen Image-Backups ist keine Zahl"), wxT("UrBackup"), wxICON_ERROR);
m_textCtrl135->SetFocus();
return;
}
if(min_image_full.ToLong(&l_min_image_full)==false )
{
wxMessageBox( _("Die minimale Anzahl an vollen Image-Backups ist keine Zahl"), wxT("UrBackup"), wxICON_ERROR);
m_textCtrl136->SetFocus();
return;
}
if(max_image_full.ToLong(&l_max_image_full)==false )
{
wxMessageBox( _("Die maximale Anzahl an vollen Image-Backups ist keine Zahl"), wxT("UrBackup"), wxICON_ERROR);
m_textCtrl137->SetFocus();
return;
}
l_update_freq_image_full_orig=l_update_freq_image_full;
if(m_checkBox1->GetValue()==false)
{
l_update_freq_image_full=-1;
}
std::map<std::string, std::string> n_vals;
n_vals["update_freq_incr"]=nconvert(l_update_freq_incr*60*60);
n_vals["update_freq_full"]=nconvert(l_update_freq_full*24*60*60);
n_vals["update_freq_image_full"]=nconvert(l_update_freq_image_full*24*60*60);
n_vals["update_freq_image_full_orig"]=nconvert(l_update_freq_image_full_orig*24*60*60);
n_vals["update_freq_image_incr"]=nconvert(l_update_freq_image_incr*24*60*60);
n_vals["max_file_incr"]=nconvert(l_max_file_incr);
n_vals["min_file_incr"]=nconvert(l_min_file_incr);
n_vals["max_file_full"]=nconvert(l_max_file_full);
n_vals["min_file_full"]=nconvert(l_min_file_full);
n_vals["min_image_incr"]=nconvert(l_min_image_incr);
n_vals["max_image_incr"]=nconvert(l_max_image_incr);
n_vals["min_image_full"]=nconvert(l_min_image_full);
n_vals["max_image_full"]=nconvert(l_max_image_full);
std::string ndata;
std::vector<std::wstring> keys=settings->getKeys();
for(size_t i=0;i<keys.size();++i)
{
std::string key=ConvertToUTF8(keys[i]);
ndata+=key+"=";
std::map<std::string, std::string>::iterator iter=n_vals.find(key);
if(iter!=n_vals.end())
{
ndata+=iter->second;
}
else
{
std::wstring val;
if(settings->getValue(keys[i], &val) )
ndata+=ConvertToUTF8(val);
}
ndata+="\n";
}
for(std::map<std::string, std::string>::iterator it=n_vals.begin();it!=n_vals.end();++it)
{
bool found=false;
const std::string &nkey=it->first;
for(size_t i=0;i<keys.size();++i)
{
if(ConvertToUTF8(keys[i])==nkey)
{
found=true;
break;
}
}
if(!found)
{
ndata+=nkey+"="+it->second+"\n";
}
}
Connector::updateSettings(ndata);
Close();
}
void Settings::OnAbortClick( wxCommandEvent& event )
{
Close();
}
void Settings::OnDisableImageBackups( wxCommandEvent& event )
{
if(m_checkBox1->GetValue()==false)
{
m_textCtrl21->Enable(false);
m_textCtrl22->Enable(false);
}
else
{
m_textCtrl21->Enable(true);
m_textCtrl22->Enable(true);
}
}

38
Settings.h Normal file
View File

@ -0,0 +1,38 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include <wx/wx.h>
#include "Connector.h"
#include "gui/GUI.h"
#include "FileSettingsReader.h"
class Settings : public GUISettings
{
public:
Settings(wxWindow* parent);
~Settings(void);
virtual void OnOkClick( wxCommandEvent& event );
virtual void OnAbortClick( wxCommandEvent& event );
virtual void OnDisableImageBackups( wxCommandEvent& event );
private:
CFileSettingsReader *settings;
};

142
TaskBarBaloon.cpp Normal file
View File

@ -0,0 +1,142 @@
#include "TaskBarBaloon.h"
#include <wx/utils.h>
#include <wx/stdpaths.h>
#include "stringtools.h"
const int TIMER_BALOON=34;
BEGIN_EVENT_TABLE(TaskBarBaloon, wxFrame)
EVT_PAINT(TaskBarBaloon::OnPaint)
EVT_LEFT_DOWN(TaskBarBaloon::OnClick)
EVT_KEY_DOWN(TaskBarBaloon::OnEscape)
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)
{
wxColour bgColour(255,255,231); // yellow BG
this->SetBackgroundColour(bgColour);
wxBoxSizer * mainSizer = new wxBoxSizer(wxVERTICAL);
wxStaticText * title = new wxStaticText(this, -1, sTitle);
wxFont titleFont = this->GetFont();
titleFont.SetWeight(wxFONTWEIGHT_BOLD);
title->SetFont(titleFont);
mainSizer->Add(title,0,wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5);
title->Connect(wxEVT_LEFT_DOWN,
wxMouseEventHandler(TaskBarBaloon::OnClick), NULL, this );
title->Connect(wxEVT_KEY_DOWN,
wxKeyEventHandler(TaskBarBaloon::OnEscape), NULL, this );
wxStaticText * text = new wxStaticText(this, -1, sMessage);
mainSizer->Add(text,1,wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 5);
text->Connect(wxEVT_LEFT_DOWN,
wxMouseEventHandler(TaskBarBaloon::OnClick), NULL, this );
text->Connect(wxEVT_KEY_DOWN,
wxKeyEventHandler(TaskBarBaloon::OnEscape), NULL, this );
this->SetSizer(mainSizer);
mainSizer->SetSizeHints( this );
this->timer = new wxTimer(this,TIMER_BALOON);
// here, we try to align the frame to the right bottom corner
this->Center();
int iX = 0, iY = 0;
this->GetPosition( &iX, &iY );
iX = (iX * 2) - 2;
iY = (iY * 2) - 2;
this->Move( iX, iY );
}
void TaskBarBaloon::OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
int iWidth = 0, iHeight = 0;
this->GetClientSize( &iWidth, &iHeight );
wxPen pen(this->GetForegroundColour());
dc.SetPen(pen);
wxBrush brush(this->GetBackgroundColour());
dc.SetBrush(brush);
dc.Clear();
dc.DrawRectangle(0,0,iWidth,iHeight);
}
/** closing frame at end of timeout */
void TaskBarBaloon::OnTimerTick(wxTimerEvent & event)
{
this->Destroy();
}
/** showing frame and running timer */
void TaskBarBaloon::showBaloon(unsigned int iTimeout)
{
this->Show(false);
this->Show(true);
this->timer->Start(iTimeout,wxTIMER_ONE_SHOT);
}
HANDLE ExecuteProcessO( const std::string & CommandLine, const std::string & WorkDir )
{
STARTUPINFOA sStartInfo;
ZeroMemory( &sStartInfo, sizeof(STARTUPINFO) );
sStartInfo.cb = sizeof(STARTUPINFO);
sStartInfo.wShowWindow = SW_SHOWDEFAULT;
sStartInfo.dwFlags = STARTF_USESHOWWINDOW;
PROCESS_INFORMATION sProcessInfo;
ZeroMemory( &sProcessInfo, sizeof(PROCESS_INFORMATION) );
BOOL ok = CreateProcessA( NULL, (char*)CommandLine.c_str(),
NULL, NULL, true,
NORMAL_PRIORITY_CLASS, NULL, WorkDir.c_str() , &sStartInfo, &sProcessInfo );
if ( !ok ) {
sProcessInfo.hProcess = 0;
return sProcessInfo.hProcess;
}
return sProcessInfo.hProcess;
}
HANDLE ExecuteProcess( const std::string & exe, const std::string &args, const std::string & WorkDir )
{
std::string cmd="\""+exe+"\"";
if( args!="" )
cmd+=" "+args;
HANDLE h=ExecuteProcessO(cmd, WorkDir);
if( h!=NULL )
return h;
SHELLEXECUTEINFOA TempInfo = {0};
TempInfo.cbSize = sizeof(SHELLEXECUTEINFOA);
TempInfo.fMask = 0; //SEE_MASK_NOCLOSEPROCESS
TempInfo.hwnd = NULL;
TempInfo.lpVerb = "runas";
TempInfo.lpFile = exe.c_str();
TempInfo.lpParameters = args.c_str();
TempInfo.lpDirectory = WorkDir.c_str();
TempInfo.nShow = SW_NORMAL;
BOOL b=ShellExecuteExA(&TempInfo);
if( b==TRUE )
{
return (HANDLE)1;
}
else
return NULL;
}
void TaskBarBaloon::OnClick(wxMouseEvent & event)
{
this->Show(false);
wxStandardPaths sp;
std::string e_pstr=ExtractFilePath(sp.GetExecutablePath().ToStdString());
ExecuteProcess(e_pstr+"\\UrBackupUpdate.exe","","");
}

27
TaskBarBaloon.h Normal file
View File

@ -0,0 +1,27 @@
#include <wx/wx.h>
#include <wx/taskbar.h>
#include <wx/frame.h>
class TaskBarBaloon : public wxFrame
{
public:
TaskBarBaloon(wxString sTitle, wxString sMessage);
virtual ~TaskBarBaloon() { delete timer; }
/** painting bg */
void OnPaint(wxPaintEvent& event);
/** timer to close window */
void OnTimerTick(wxTimerEvent & event);
/** click on the baloon */
void OnClick(wxMouseEvent & event);
/** click on the baloon */
void OnEscape(wxKeyEvent & event){};
/** display the baloon and run the timer */
void showBaloon(unsigned int iTimeout);
private:
wxTimer * timer;
DECLARE_EVENT_TABLE();
};

151
TrayIcon.cpp Normal file
View File

@ -0,0 +1,151 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "TrayIcon.h"
#include "ConfigPath.h"
#include "Settings.h"
#include "Logs.h"
#include "main.h"
#include "Connector.h"
#include "Info.h"
#define ID_TI_EXIT 100
#define ID_TI_ADD_PATH 101
#define ID_TI_BACKUP_FULL 102
#define ID_TI_BACKUP_INCR 103
#define ID_TI_SEP -1
#define ID_TI_SETTINGS 104
#define ID_TI_LOGS 105
#define ID_TI_BACKUP_IMAGE_FULL 106
#define ID_TI_BACKUP_IMAGE_INCR 107
#define ID_TI_PAUSE 108
#define ID_TI_CONTINUE 109
#define ID_TI_INFO 110
extern MyTimer *timer;
extern int working_status;
bool b_is_pausing=false;
extern MyTimer *timer;
void TrayIcon::OnPopupClick(wxCommandEvent &evt)
{
if(evt.GetId()==ID_TI_EXIT)
{
wxExit();
return;
}
if(evt.GetId()==ID_TI_ADD_PATH)
{
ConfigPath *cp=new ConfigPath();
}
else if(evt.GetId()==ID_TI_BACKUP_FULL || evt.GetId()==ID_TI_BACKUP_INCR)
{
bool full= (evt.GetId()==ID_TI_BACKUP_FULL);
int rc=Connector::startBackup(full);
if(rc==1)
{
SetIcon(wxIcon(wxT("backup-progress.ico"), wxBITMAP_TYPE_ICO), wxT("Warte auf Server..."));
if(timer!=NULL)
timer->Start(1000);
}
else if(rc==2)
wxMessageBox( _("Ein Backup läuft bereits. Konnte leider kein weiteres starten."), wxT("UrBackup"), wxICON_EXCLAMATION);
else
wxMessageBox( _("Konnte kein Backup starten, da leider kein Server gefunden wurde"), wxT("UrBackup"), wxICON_ERROR);
}
else if(evt.GetId()==ID_TI_SETTINGS)
{
Settings *s=new Settings(NULL);
}
else if(evt.GetId()==ID_TI_LOGS)
{
Logs *l=new Logs(NULL);
}
else if(evt.GetId()==ID_TI_BACKUP_IMAGE_FULL || evt.GetId()==ID_TI_BACKUP_IMAGE_INCR)
{
bool full= (evt.GetId()==ID_TI_BACKUP_IMAGE_FULL);
int rc=Connector::startImage(full);
if(rc==1)
{
SetIcon(wxIcon(wxT("backup-progress.ico"), wxBITMAP_TYPE_ICO), wxT("Warte auf Server..."));
if(timer!=NULL)
timer->Start(1000);
}
else if(rc==2)
wxMessageBox( _("Ein Backup läuft bereits. Konnte leider kein weiteres starten."), wxT("UrBackup"), wxICON_EXCLAMATION);
else
wxMessageBox( _("Konnte kein Backup starten, da leider kein Server gefunden wurde"), wxT("UrBackup"), wxICON_ERROR);
}
else if(evt.GetId()==ID_TI_PAUSE)
{
if(Connector::setPause(true))
{
b_is_pausing=true;
if(timer!=NULL)
timer->Notify();
}
else
{
wxMessageBox( _("Verbindung mit Backupserver fehlgeschlagen. Konnte nicht pausieren."), wxT("UrBackup"), wxICON_ERROR);
}
}
else if(evt.GetId()==ID_TI_CONTINUE)
{
if(Connector::setPause(false))
{
b_is_pausing=false;
if(timer!=NULL)
timer->Notify();
}
else
{
wxMessageBox( _("Verbindung mit Backupserver fehlgeschlagen. Konnte nicht fortfahren."), wxT("UrBackup"), wxICON_ERROR);
}
}
else if(evt.GetId()==ID_TI_INFO )
{
Info *i=new Info(NULL);
}
}
wxMenu* TrayIcon::CreatePopupMenu(void)
{
wxMenu *mnu=new wxMenu();
mnu->Append(ID_TI_BACKUP_FULL, _("Volles Backup jetzt"), wxT("Jetzt ein volles Backup ausführen"));
mnu->Append(ID_TI_BACKUP_INCR, _("Inkremetelles Backup jetzt"), wxT("Jetzt ein inkrementelles Backup ausführen"));
mnu->Append(ID_TI_BACKUP_IMAGE_FULL, _("Volles Image-Backup jetzt"), wxT("Jetzt ein inkrementelles Image-Backup ausführen"));
mnu->Append(ID_TI_BACKUP_IMAGE_INCR, _("Inkremetelles Image-Backup jetzt"), wxT("Jetzt ein inkrementelles Image-Backup ausführen"));
mnu->AppendSeparator();
mnu->Append(ID_TI_SETTINGS, _("Einstellungen") );
mnu->Append(ID_TI_ADD_PATH, _("Pfade konfigurieren"));
mnu->Append(ID_TI_LOGS, _("Logs") );
mnu->Append(ID_TI_INFO, _("Info") );
if(working_status>0)
{
if(b_is_pausing==false)
{
mnu->Append(ID_TI_PAUSE, _("Pausieren"));
}
else
{
mnu->Append(ID_TI_CONTINUE, _("Fortfahren"));
}
}
mnu->Connect(wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction)&TrayIcon::OnPopupClick, NULL, this);
return mnu;
}

28
TrayIcon.h Normal file
View File

@ -0,0 +1,28 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include <wx/wx.h>
#include <wx/taskbar.h>
#include <wx/menu.h>
class TrayIcon : public wxTaskBarIcon
{
public:
wxMenu* CreatePopupMenu(void);
void OnPopupClick(wxCommandEvent &evt);
};

72
UrBackupClientGUI.rc Normal file
View File

@ -0,0 +1,72 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Deutsch (Deutschland) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
#ifdef _WIN32
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON "icon1.ico"
#endif // Deutsch (Deutschland) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

20
UrBackupClientGUI.sln Normal file
View File

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UrBackupClientGUI", "UrBackupClientGUI.vcxproj", "{7169B7EA-2630-4042-A0DC-19471462C1C3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7169B7EA-2630-4042-A0DC-19471462C1C3}.Debug|Win32.ActiveCfg = Debug|Win32
{7169B7EA-2630-4042-A0DC-19471462C1C3}.Debug|Win32.Build.0 = Debug|Win32
{7169B7EA-2630-4042-A0DC-19471462C1C3}.Release|Win32.ActiveCfg = Release|x64
{7169B7EA-2630-4042-A0DC-19471462C1C3}.Release|Win32.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

223
UrBackupClientGUI.vcxproj Normal file
View File

@ -0,0 +1,223 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{7169B7EA-2630-4042-A0DC-19471462C1C3}</ProjectGuid>
<RootNamespace>UrBackupClientGUI</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>D:\Developement\libs\wxWidgets-2.9.1\include;wx86\mswud;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>wxpngd.lib;wxbase29ud.lib;wxmsw29ud_core.lib;wxmsw29ud_adv.lib;wxexpatd.lib;comctl32.lib;Rpcrt4.lib;wxbase29ud_net.lib;ws2_32.lib;wxpngd.lib;wxzlibd.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>wx86\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>D:\Developement\libs\wxWidgets-2.9.1\include;wx86\mswu\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;DD_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>wxbase29u.lib;wxmsw29u_core.lib;wxmsw29u_adv.lib;wxexpat.lib;comctl32.lib;Rpcrt4.lib;wxbase29u_net.lib;ws2_32.lib;wxpng.lib;wxzlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>wx86/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>D:\Developement\libs\wxWidgets-2.8.10\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>wxpngd.lib;wxbase28ud.lib;wxmsw28ud_core.lib;wxmsw28ud_adv.lib;wxexpatd.lib;comctl32.lib;Rpcrt4.lib;wxbase28ud_net.lib;ws2_32.lib;wxpngd.lib;wxzlibd.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>D:\Developement\libs\wxWidgets-2.8.10\lib\vc_lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>D:\Developement\libs\wxWidgets-2.9.1\include;wx64\mswu\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;DD_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>wxbase29u.lib;wxmsw29u_core.lib;wxmsw29u_adv.lib;wxexpat.lib;comctl32.lib;Rpcrt4.lib;wxbase29u_net.lib;ws2_32.lib;wxpng.lib;wxzlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>wx64/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="ConfigPath.cpp" />
<ClCompile Include="Connector.cpp" />
<ClCompile Include="escape.cpp" />
<ClCompile Include="FileSettingsReader.cpp" />
<ClCompile Include="Info.cpp" />
<ClCompile Include="Logs.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="Settings.cpp" />
<ClCompile Include="stringtools.cpp" />
<ClCompile Include="TaskBarBaloon.cpp" />
<ClCompile Include="tcpstack.cpp" />
<ClCompile Include="TrayIcon.cpp" />
<ClCompile Include="gui\GUI.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="ConfigPath.h" />
<ClInclude Include="Connector.h" />
<ClInclude Include="escape.h" />
<ClInclude Include="FileSettingsReader.h" />
<ClInclude Include="Info.h" />
<ClInclude Include="Logs.h" />
<ClInclude Include="main.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="Settings.h" />
<ClInclude Include="stringtools.h" />
<ClInclude Include="TaskBarBaloon.h" />
<ClInclude Include="tcpstack.h" />
<ClInclude Include="TrayIcon.h" />
<ClInclude Include="gui\GUI.h" />
</ItemGroup>
<ItemGroup>
<None Include="icon1.ico" />
<None Include="icon2.ico" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="UrBackupClientGUI.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,118 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Quelldateien">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Headerdateien">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Ressourcendateien">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
<Filter Include="GUI">
<UniqueIdentifier>{59437933-cec2-425e-b03b-fa40069e48bb}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="ConfigPath.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="Connector.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="escape.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="FileSettingsReader.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="Info.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="Logs.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="Settings.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="stringtools.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="tcpstack.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="TrayIcon.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="gui\GUI.cpp">
<Filter>GUI</Filter>
</ClCompile>
<ClCompile Include="TaskBarBaloon.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ConfigPath.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="Connector.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="escape.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="FileSettingsReader.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="Info.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="Logs.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="main.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="Settings.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="stringtools.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="tcpstack.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="TrayIcon.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="gui\GUI.h">
<Filter>GUI</Filter>
</ClInclude>
<ClInclude Include="TaskBarBaloon.h">
<Filter>Headerdateien</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="icon1.ico">
<Filter>Ressourcendateien</Filter>
</None>
<None Include="icon2.ico">
<Filter>Ressourcendateien</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="UrBackupClientGUI.rc">
<Filter>Ressourcendateien</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

BIN
backup-bad.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
backup-ok.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
backup-progress-pause.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
backup-progress.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

97
escape.cpp Normal file
View File

@ -0,0 +1,97 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include <string>
void unescapeMessage(std::string &msg)
{
for(size_t i=0;i<msg.size();++i)
{
if(msg[i]=='$')
{
if(i+1<msg.size() )
{
bool ok=false;
if(msg[i+1]=='$')
{
ok=true;
}
else if(msg[i+1]=='r')
{
ok=true;
msg[i]='#';
}
if(ok)
{
msg.erase(msg.begin()+i+1);
}
}
}
}
}
void escapeClientMessage(std::string &msg)
{
for(size_t i=0;i<msg.size();++i)
{
if(msg[i]=='#' )
{
msg[i]='$';
msg.insert(i+1, "r");
}
else if(msg[i]=='$')
{
msg.insert(i+1, "$");
++i;
}
}
}
bool testEscape(void)
{
std::string msg1="Das ist ein # test";
std::string msg2="Das ist ein test";
std::string msg3="Das ist ein ## test";
std::string msg4="##Das ist ein # test##";
std::string msg5="$$Das ist ein # test$$";
std::string msg6="Das ist ein $ test";
escapeClientMessage(msg1);
if(msg1!="Das ist ein $r test")
return false;
escapeClientMessage(msg2);
escapeClientMessage(msg3);
escapeClientMessage(msg4);
if(msg4!="$r$rDas ist ein $r test$r$r")
return false;
escapeClientMessage(msg5);
escapeClientMessage(msg6);
unescapeMessage(msg1);
unescapeMessage(msg2);
unescapeMessage(msg3);
unescapeMessage(msg4);
unescapeMessage(msg5);
unescapeMessage(msg6);
if(msg1!="Das ist ein # test") return false;
if(msg2!="Das ist ein test") return false;
if(msg3!="Das ist ein ## test") return false;
if(msg4!="##Das ist ein # test##") return false;
if(msg5!="$$Das ist ein # test$$") return false;
if(msg6!="Das ist ein $ test") return false;
return true;
}

22
escape.h Normal file
View File

@ -0,0 +1,22 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include <string>
void unescapeMessage(std::string &msg);
void escapeClientMessage(std::string &msg);

7
gettext-names.txt Normal file
View File

@ -0,0 +1,7 @@
gui/GUI.cpp
ConfigPath.cpp
Logs.cpp
main.cpp
Settings.cpp
TaskBarBaloon.cpp
TrayIcon.cpp

416
gui/GUI.cpp Normal file
View File

@ -0,0 +1,416 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "GUI.h"
///////////////////////////////////////////////////////////////////////////
GUISettings::GUISettings( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSize(541,543);
this->SetSizeHints( wxSize( 541,543 ), wxDefaultSize );
wxBoxSizer* bSizer1;
bSizer1 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer2;
bSizer2 = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizer5;
bSizer5 = new wxBoxSizer( wxVERTICAL );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Intervall für inkrementelle Backups:"), wxDefaultPosition, wxSize( -1,22 ), 0 );
m_staticText1->Wrap( -1 );
bSizer5->Add( m_staticText1, 0, wxALL, 5 );
m_staticText3 = new wxStaticText( this, wxID_ANY, _("Intervall für volle Backups:"), wxDefaultPosition, wxSize( -1,22 ), 0 );
m_staticText3->Wrap( -1 );
bSizer5->Add( m_staticText3, 0, wxALL, 5 );
m_staticText6 = new wxStaticText( this, wxID_ANY, _("Intervall für inkrementelle Image-Backups:"), wxDefaultPosition, wxSize( -1,22 ), 0 );
m_staticText6->Wrap( -1 );
bSizer5->Add( m_staticText6, 0, wxALL, 5 );
m_staticText7 = new wxStaticText( this, wxID_ANY, _("Intervall für volle Image-Backups:"), wxDefaultPosition, wxSize( -1,22 ), 0 );
m_staticText7->Wrap( -1 );
bSizer5->Add( m_staticText7, 0, wxALL, 5 );
m_staticText8 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,15 ), 0 );
m_staticText8->Wrap( -1 );
bSizer5->Add( m_staticText8, 0, wxALL, 5 );
m_staticText9 = new wxStaticText( this, wxID_ANY, _("Minimale Anzahl an inkrementellen Backups:"), wxDefaultPosition, wxSize( -1,22 ), 0 );
m_staticText9->Wrap( -1 );
bSizer5->Add( m_staticText9, 0, wxALL, 5 );
m_staticText10 = new wxStaticText( this, wxID_ANY, _("Maximale Anzahl an inkrementellen Backups:"), wxDefaultPosition, wxSize( -1,22 ), 0 );
m_staticText10->Wrap( -1 );
bSizer5->Add( m_staticText10, 0, wxALL, 5 );
m_staticText11 = new wxStaticText( this, wxID_ANY, _("Minimale Anzahl an vollen Backups:"), wxDefaultPosition, wxSize( -1,22 ), 0 );
m_staticText11->Wrap( -1 );
bSizer5->Add( m_staticText11, 0, wxALL, 5 );
m_staticText12 = new wxStaticText( this, wxID_ANY, _("Maximale Anzahl an vollen Backups:"), wxDefaultPosition, wxSize( -1,22 ), 0 );
m_staticText12->Wrap( -1 );
bSizer5->Add( m_staticText12, 0, wxALL, 5 );
m_staticText13 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,20 ), 0 );
m_staticText13->Wrap( -1 );
bSizer5->Add( m_staticText13, 0, wxALL, 5 );
m_staticText14 = new wxStaticText( this, wxID_ANY, _("Minimale Anzahl an inkrementellen Image-Backups:"), wxDefaultPosition, wxSize( -1,22 ), 0 );
m_staticText14->Wrap( -1 );
bSizer5->Add( m_staticText14, 0, wxALL, 5 );
m_staticText15 = new wxStaticText( this, wxID_ANY, _("Maximale Anzahl an inkrementellen Image-Backups:"), wxDefaultPosition, wxSize( -1,22 ), 0 );
m_staticText15->Wrap( -1 );
bSizer5->Add( m_staticText15, 0, wxALL, 5 );
m_staticText16 = new wxStaticText( this, wxID_ANY, _("Minimale Anzahl an vollen Image-Backups:"), wxDefaultPosition, wxSize( -1,22 ), 0 );
m_staticText16->Wrap( -1 );
bSizer5->Add( m_staticText16, 0, wxALL, 5 );
m_staticText17 = new wxStaticText( this, wxID_ANY, _("Maximale Anzahl an vollen Image-Backups:"), wxDefaultPosition, wxSize( -1,22 ), 0 );
m_staticText17->Wrap( -1 );
bSizer5->Add( m_staticText17, 0, wxALL, 5 );
bSizer2->Add( bSizer5, 2, 0, 5 );
wxBoxSizer* bSizer6;
bSizer6 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxHORIZONTAL );
m_textCtrl1 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer7->Add( m_textCtrl1, 0, wxALL, 5 );
m_staticText2 = new wxStaticText( this, wxID_ANY, _("Stunden"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText2->Wrap( -1 );
bSizer7->Add( m_staticText2, 0, wxALL, 5 );
bSizer6->Add( bSizer7, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer8;
bSizer8 = new wxBoxSizer( wxHORIZONTAL );
m_textCtrl2 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer8->Add( m_textCtrl2, 0, wxALL, 5 );
m_staticText4 = new wxStaticText( this, wxID_ANY, _("Tage"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText4->Wrap( -1 );
bSizer8->Add( m_staticText4, 0, wxALL, 5 );
bSizer6->Add( bSizer8, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer81;
bSizer81 = new wxBoxSizer( wxHORIZONTAL );
m_textCtrl21 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer81->Add( m_textCtrl21, 0, wxALL, 5 );
m_staticText41 = new wxStaticText( this, wxID_ANY, _("Tage"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText41->Wrap( -1 );
bSizer81->Add( m_staticText41, 0, wxALL, 5 );
bSizer81->Add( 0, 0, 1, wxEXPAND, 5 );
m_checkBox1 = new wxCheckBox( this, wxID_ANY, _("Aktiv"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBox1->SetValue(true);
bSizer81->Add( m_checkBox1, 0, wxALL, 5 );
bSizer6->Add( bSizer81, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer82;
bSizer82 = new wxBoxSizer( wxHORIZONTAL );
m_textCtrl22 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer82->Add( m_textCtrl22, 0, wxALL, 5 );
m_staticText42 = new wxStaticText( this, wxID_ANY, _("Tage"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText42->Wrap( -1 );
bSizer82->Add( m_staticText42, 0, wxALL, 5 );
bSizer6->Add( bSizer82, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer24;
bSizer24 = new wxBoxSizer( wxVERTICAL );
bSizer6->Add( bSizer24, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer26;
bSizer26 = new wxBoxSizer( wxVERTICAL );
m_textCtrl13 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer26->Add( m_textCtrl13, 0, wxALL, 5 );
bSizer6->Add( bSizer26, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer261;
bSizer261 = new wxBoxSizer( wxVERTICAL );
m_textCtrl131 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer261->Add( m_textCtrl131, 0, wxALL, 5 );
bSizer6->Add( bSizer261, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer262;
bSizer262 = new wxBoxSizer( wxVERTICAL );
m_textCtrl132 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer262->Add( m_textCtrl132, 0, wxALL, 5 );
bSizer6->Add( bSizer262, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer263;
bSizer263 = new wxBoxSizer( wxVERTICAL );
m_textCtrl133 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer263->Add( m_textCtrl133, 0, wxALL, 5 );
bSizer6->Add( bSizer263, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer34;
bSizer34 = new wxBoxSizer( wxVERTICAL );
bSizer34->SetMinSize( wxSize( -1,31 ) );
bSizer6->Add( bSizer34, 1, wxEXPAND|wxFIXED_MINSIZE, 5 );
wxBoxSizer* bSizer264;
bSizer264 = new wxBoxSizer( wxVERTICAL );
m_textCtrl134 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer264->Add( m_textCtrl134, 0, wxALL, 5 );
bSizer6->Add( bSizer264, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer265;
bSizer265 = new wxBoxSizer( wxVERTICAL );
m_textCtrl135 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer265->Add( m_textCtrl135, 0, wxALL, 5 );
bSizer6->Add( bSizer265, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer266;
bSizer266 = new wxBoxSizer( wxVERTICAL );
m_textCtrl136 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer266->Add( m_textCtrl136, 0, wxALL, 5 );
bSizer6->Add( bSizer266, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer267;
bSizer267 = new wxBoxSizer( wxVERTICAL );
m_textCtrl137 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer267->Add( m_textCtrl137, 0, wxALL, 5 );
bSizer6->Add( bSizer267, 1, wxEXPAND, 5 );
bSizer6->Add( 0, 0, 1, wxEXPAND, 5 );
bSizer2->Add( bSizer6, 2, 0, 5 );
bSizer1->Add( bSizer2, 15, wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxHORIZONTAL );
bSizer4->SetMinSize( wxSize( -1,50 ) );
bSizer4->Add( 0, 0, 1, wxEXPAND, 5 );
m_button1 = new wxButton( this, wxID_ANY, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
m_button1->SetMinSize( wxSize( -1,25 ) );
bSizer4->Add( m_button1, 0, wxALL, 5 );
m_button2 = new wxButton( this, wxID_ANY, _("Abbrechen"), wxDefaultPosition, wxDefaultSize, 0 );
m_button2->SetMinSize( wxSize( -1,25 ) );
bSizer4->Add( m_button2, 0, wxALL, 5 );
bSizer1->Add( bSizer4, 0, wxEXPAND|wxFIXED_MINSIZE, 5 );
this->SetSizer( bSizer1 );
this->Layout();
this->Centre( wxBOTH );
// Connect Events
m_checkBox1->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( GUISettings::OnDisableImageBackups ), NULL, this );
m_button1->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( GUISettings::OnOkClick ), NULL, this );
m_button2->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( GUISettings::OnAbortClick ), NULL, this );
}
GUISettings::~GUISettings()
{
// Disconnect Events
m_checkBox1->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( GUISettings::OnDisableImageBackups ), NULL, this );
m_button1->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( GUISettings::OnOkClick ), NULL, this );
m_button2->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( GUISettings::OnAbortClick ), NULL, this );
}
GUILogfiles::GUILogfiles( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizer8;
bSizer8 = new wxBoxSizer( wxHORIZONTAL );
m_listBox1 = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
bSizer8->Add( m_listBox1, 0, wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizer9;
bSizer9 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer11;
bSizer11 = new wxBoxSizer( wxHORIZONTAL );
bSizer11->Add( 0, 0, 1, wxEXPAND, 5 );
m_staticText5 = new wxStaticText( this, wxID_ANY, _("Filter:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText5->Wrap( -1 );
bSizer11->Add( m_staticText5, 0, wxALL, 5 );
wxString m_choice1Choices[] = { _("Info"), _("Warnings"), _("Errors") };
int m_choice1NChoices = sizeof( m_choice1Choices ) / sizeof( wxString );
m_choice1 = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choice1NChoices, m_choice1Choices, 0 );
m_choice1->SetSelection( 2 );
bSizer11->Add( m_choice1, 0, wxALL, 5 );
bSizer9->Add( bSizer11, 1, wxEXPAND, 5 );
m_textCtrl3 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
bSizer9->Add( m_textCtrl3, 15, wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizer10;
bSizer10 = new wxBoxSizer( wxHORIZONTAL );
bSizer10->Add( 0, 0, 1, wxEXPAND, 5 );
m_button5 = new wxButton( this, wxID_ANY, _(L"Verlassen"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer10->Add( m_button5, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
bSizer9->Add( bSizer10, 1, wxEXPAND|wxALIGN_RIGHT, 5 );
bSizer8->Add( bSizer9, 1, wxEXPAND, 5 );
this->SetSizer( bSizer8 );
this->Layout();
this->Centre( wxBOTH );
// Connect Events
m_listBox1->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( GUILogfiles::OnLogEntrySelect ), NULL, this );
m_choice1->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( GUILogfiles::OnLoglevelChange ), NULL, this );
m_button5->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( GUILogfiles::OnExitClick ), NULL, this );
}
GUILogfiles::~GUILogfiles()
{
// Disconnect Events
m_listBox1->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( GUILogfiles::OnLogEntrySelect ), NULL, this );
m_choice1->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( GUILogfiles::OnLoglevelChange ), NULL, this );
m_button5->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( GUILogfiles::OnExitClick ), NULL, this );
}
GUIInfo::GUIInfo( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizer24;
bSizer24 = new wxBoxSizer( wxVERTICAL );
bSizer24->Add( 0, 0, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer25;
bSizer25 = new wxBoxSizer( wxHORIZONTAL );
bSizer25->Add( 0, 0, 1, wxEXPAND, 5 );
m_bitmap1 = new wxStaticBitmap( this, wxID_ANY, wxBitmap( wxT("logo1.png"), wxBITMAP_TYPE_ANY ), wxDefaultPosition, wxDefaultSize, 0 );
m_bitmap1->SetMinSize( wxSize( 100,91 ) );
bSizer25->Add( m_bitmap1, 0, wxALL, 5 );
bSizer25->Add( 0, 0, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer26;
bSizer26 = new wxBoxSizer( wxVERTICAL );
m_staticText21 = new wxStaticText( this, wxID_ANY, _("Version:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText21->Wrap( -1 );
bSizer26->Add( m_staticText21, 0, wxALL, 5 );
m_staticText22 = new wxStaticText( this, wxID_ANY, wxT(" 0.35"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText22->Wrap( -1 );
bSizer26->Add( m_staticText22, 0, wxALL, 5 );
m_staticText23 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_staticText23->Wrap( -1 );
bSizer26->Add( m_staticText23, 0, wxALL, 5 );
m_staticText24 = new wxStaticText( this, wxID_ANY, _("Autor:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText24->Wrap( -1 );
bSizer26->Add( m_staticText24, 0, wxALL, 5 );
m_staticText25 = new wxStaticText( this, wxID_ANY, wxT(" Martin Raiber"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText25->Wrap( -1 );
bSizer26->Add( m_staticText25, 0, wxALL, 5 );
bSizer25->Add( bSizer26, 3, wxEXPAND, 5 );
bSizer24->Add( bSizer25, 6, wxEXPAND, 5 );
bSizer24->Add( 0, 0, 4, wxEXPAND, 5 );
wxBoxSizer* bSizer27;
bSizer27 = new wxBoxSizer( wxHORIZONTAL );
bSizer27->Add( 0, 0, 1, wxEXPAND, 5 );
m_button4 = new wxButton( this, wxID_ANY, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer27->Add( m_button4, 0, wxALL, 5 );
bSizer24->Add( bSizer27, 3, wxEXPAND, 5 );
this->SetSizer( bSizer24 );
this->Layout();
// Connect Events
m_button4->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( GUIInfo::OnOKClick ), NULL, this );
}
GUIInfo::~GUIInfo()
{
// Disconnect Events
m_button4->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( GUIInfo::OnOKClick ), NULL, this );
}

160
gui/GUI.h Normal file
View File

@ -0,0 +1,160 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#ifndef __GUI__
#define __GUI__
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/textctrl.h>
#include <wx/checkbox.h>
#include <wx/button.h>
#include <wx/dialog.h>
#include <wx/listbox.h>
#include <wx/choice.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/statbmp.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class GUISettings
///////////////////////////////////////////////////////////////////////////////
class GUISettings : public wxDialog
{
private:
protected:
wxStaticText* m_staticText1;
wxStaticText* m_staticText3;
wxStaticText* m_staticText6;
wxStaticText* m_staticText7;
wxStaticText* m_staticText8;
wxStaticText* m_staticText9;
wxStaticText* m_staticText10;
wxStaticText* m_staticText11;
wxStaticText* m_staticText12;
wxStaticText* m_staticText13;
wxStaticText* m_staticText14;
wxStaticText* m_staticText15;
wxStaticText* m_staticText16;
wxStaticText* m_staticText17;
wxTextCtrl* m_textCtrl1;
wxStaticText* m_staticText2;
wxTextCtrl* m_textCtrl2;
wxStaticText* m_staticText4;
wxTextCtrl* m_textCtrl21;
wxStaticText* m_staticText41;
wxCheckBox* m_checkBox1;
wxTextCtrl* m_textCtrl22;
wxStaticText* m_staticText42;
wxTextCtrl* m_textCtrl13;
wxTextCtrl* m_textCtrl131;
wxTextCtrl* m_textCtrl132;
wxTextCtrl* m_textCtrl133;
wxTextCtrl* m_textCtrl134;
wxTextCtrl* m_textCtrl135;
wxTextCtrl* m_textCtrl136;
wxTextCtrl* m_textCtrl137;
wxButton* m_button1;
wxButton* m_button2;
// Virtual event handlers, overide them in your derived class
virtual void OnDisableImageBackups( wxCommandEvent& event ){ event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnAbortClick( wxCommandEvent& event ){ event.Skip(); }
public:
GUISettings( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Einstellungen"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 541,543 ), long style = wxDEFAULT_DIALOG_STYLE );
~GUISettings();
};
///////////////////////////////////////////////////////////////////////////////
/// Class GUILogfiles
///////////////////////////////////////////////////////////////////////////////
class GUILogfiles : public wxDialog
{
private:
protected:
wxListBox* m_listBox1;
wxStaticText* m_staticText5;
wxChoice* m_choice1;
wxTextCtrl* m_textCtrl3;
wxButton* m_button5;
// Virtual event handlers, overide them in your derived class
virtual void OnLogEntrySelect( wxCommandEvent& event ){ event.Skip(); }
virtual void OnLoglevelChange( wxCommandEvent& event ){ event.Skip(); }
virtual void OnExitClick( wxCommandEvent& event ){ event.Skip(); }
public:
GUILogfiles( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Logs"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 703,522 ), long style = wxDEFAULT_DIALOG_STYLE );
~GUILogfiles();
};
///////////////////////////////////////////////////////////////////////////////
/// Class GUIInfo
///////////////////////////////////////////////////////////////////////////////
class GUIInfo : public wxDialog
{
private:
protected:
wxStaticBitmap* m_bitmap1;
wxStaticText* m_staticText21;
wxStaticText* m_staticText22;
wxStaticText* m_staticText23;
wxStaticText* m_staticText24;
wxStaticText* m_staticText25;
wxButton* m_button4;
// Virtual event handlers, overide them in your derived class
virtual void OnOKClick( wxCommandEvent& event ){ event.Skip(); }
public:
GUIInfo( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Informationen"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 313,215 ), long style = wxDEFAULT_DIALOG_STYLE );
~GUIInfo();
};
#endif //__GUI__

2924
gui/settings.fbp Normal file

File diff suppressed because it is too large Load Diff

BIN
icon1.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
icon2.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
logo1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

317
main.cpp Normal file
View File

@ -0,0 +1,317 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "TrayIcon.h"
#include "ConfigPath.h"
#include "main.h"
#include "stringtools.h"
#include "TaskBarBaloon.h"
#include <iostream>
#include <wx/stdpaths.h>
#include <wx/dir.h>
#include <wx/filename.h>
#include <wx/apptrait.h>
/*#if wxUSE_STACKWALKER && defined( __WXDEBUG__ )
// silly workaround for the link error with debug configuration:
// \src\common\appbase.cpp
wxString wxAppTraitsBase::GetAssertStackTrace()
{
return wxT("");
}
#endif*/
#ifdef _WIN32
#include <windows.h>
#endif
TrayIcon *tray;
MyTimer *timer;
int icon_type=0;
wxString last_status;
unsigned int incr_update_intervall=2*60*60+10*60;
bool incr_update_done=false;
int working_status=0;
#ifndef DD_RELEASE
IMPLEMENT_APP_NO_MAIN(MyApp)
#endif
class TheFrame : public wxFrame {
public:
TheFrame(void) : wxFrame(NULL, -1, wxT("UrBackupGUI")) { }
};
bool MyApp::OnInit()
{
#ifdef _WIN32
#ifndef _DEBUG
wchar_t buf[MAX_PATH];
GetModuleFileNameW(NULL, buf, MAX_PATH);
SetCurrentDirectoryW(ExtractFilePath(buf).c_str() );
#endif
#endif
wxLanguage lang=wxLANGUAGE_ENGLISH;
wxLanguage sysdef=(wxLanguage)wxLocale::GetSystemLanguage();
switch(sysdef)
{
case wxLANGUAGE_GERMAN:
case wxLANGUAGE_GERMAN_AUSTRIAN:
case wxLANGUAGE_GERMAN_BELGIUM:
case wxLANGUAGE_GERMAN_LIECHTENSTEIN:
case wxLANGUAGE_GERMAN_LUXEMBOURG:
case wxLANGUAGE_GERMAN_SWISS:
lang=wxLANGUAGE_GERMAN;
break;
}
m_locale.Init(lang, wxLOCALE_DONT_LOAD_DEFAULT);
m_locale.AddCatalog("trans");
this->SetTopWindow(new TheFrame);
wxImage::AddHandler(new wxPNGHandler);
tray=new TrayIcon;
bool b=tray->SetIcon(wxIcon(wxT("backup-ok.ico"), wxBITMAP_TYPE_ICO), wxT("UrBackup Client"));
if(!b)
{
std::cout << "Setting icon failed." << std::endl;
}
timer=new MyTimer;
timer->Notify();
timer->Start(60000);
return true;
}
int MyApp::OnExit()
{
exit(0);
return 0;
}
void MyTimer::Notify()
{
static bool working=false;
if(working==true)
{
return;
}
if(Connector::isBusy())
{
return;
}
working=true;
wxStandardPaths sp;
static wxString cfgDir=sp.GetUserDataDir();
static long starttime=wxGetLocalTime();
static long startuptime_passed=0;
static long lastbackuptime=-5*60*1000;
static long lastversioncheck=starttime;
if(!wxDir::Exists(cfgDir) )
{
wxFileName::Mkdir(cfgDir);
}
if(startuptime_passed==0)
{
startuptime_passed=atoi(getFile((cfgDir+wxT("/passedtime.cfg") ).ToUTF8().data() ).c_str() );
startuptime_passed+=atoi(getFile((cfgDir+wxT("/passedtime_new.cfg") ).ToUTF8().data() ).c_str() );
writestring(nconvert(startuptime_passed), (cfgDir+wxT("/passedtime.cfg") ).ToUTF8().data() );
lastbackuptime=atoi(getFile((cfgDir+wxT("/lastbackuptime.cfg") ).ToUTF8().data() ).c_str() );
if(lastbackuptime==0)
lastbackuptime=-5*60*1000;
std::string update_intv=getFile((cfgDir+wxT("/incr_updateintervall.cfg") ).ToUTF8().data() );
if(!update_intv.empty())
incr_update_intervall=atoi(update_intv.c_str());
}
long ct=wxGetLocalTime();
if(ct-lastversioncheck>300)
{
std::string n_version=getFile("version.txt");
std::string c_version=getFile("curr_version.txt");
if(n_version.empty())n_version="0";
if(c_version.empty())c_version="0";
if( atoi(n_version.c_str())>atoi(c_version.c_str()))
{
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);
}
ct=wxGetLocalTime();
lastversioncheck=ct;
}
long passed=( ct-starttime );
writestring(nconvert(passed), (cfgDir+wxT("/passedtime_new.cfg") ).ToUTF8().data() );
wxString status_text;
SStatus status=Connector::getStatus();
if(Connector::hasError() )
{
if(icon_type!=4)
{
last_status=_("Keine Verbindung zum Backupserver möglich");
if(tray!=NULL)
tray->SetIcon(wxIcon(wxT("backup-bad.ico"), wxBITMAP_TYPE_ICO), last_status);
icon_type=4;
}
working=false;
return;
}
int last_icon_type=icon_type;
if(status.status==wxT("DONE") )
{
writestring(nconvert(startuptime_passed+passed), (cfgDir+wxT("/lastbackuptime.cfg") ).ToUTF8().data() );
lastbackuptime=startuptime_passed+passed;
icon_type=0;
working_status=0;
}
else if(status.status==wxT("INCR") )
{
status_text+=_("Inkrementelles Backup läuft. ");
if(!status.pcdone.empty())
{
status_text+=status.pcdone;
status_text+=wxT("% fertig. ");
}
icon_type=1;
working_status=1;
}
else if(status.status==wxT("FULL") )
{
status_text+=_("Volles Backup läuft. ");
if(!status.pcdone.empty())
{
status_text+=status.pcdone;
status_text+=wxT("% fertig. ");
}
icon_type=1;
working_status=2;
}
else if(status.status==wxT("INCRI") )
{
status_text+=_("Inkrementelles Image-Backup läuft. ");
if(!status.pcdone.empty())
{
status_text+=status.pcdone;
status_text+=wxT("% fertig. ");
}
icon_type=1;
working_status=3;
}
else if(status.status==wxT("FULLI") )
{
status_text+=_("Volles Image-Backup läuft. ");
if(!status.pcdone.empty())
{
status_text+=status.pcdone;
status_text+=wxT("% fertig. ");
}
icon_type=1;
working_status=4;
}
else if(startuptime_passed+passed-(long)incr_update_intervall>lastbackuptime)
{
status_text+=_("Kein aktuelles Backup. ");
icon_type=2;
working_status=0;
}
else
{
icon_type=0;
working_status=0;
}
if(!status.lastbackupdate.Trim().empty() )
status_text+=_("Letztes Backup am ")+status.lastbackupdate;
if( icon_type<3 && incr_update_done==false)
{
unsigned int n_incr_update_intervall=Connector::getIncrUpdateIntervall();
if(!Connector::hasError() && n_incr_update_intervall!=0)
{
incr_update_done=true;
incr_update_intervall=n_incr_update_intervall;
writestring(nconvert(incr_update_intervall), (cfgDir+wxT("/incr_updateintervall.cfg") ).ToUTF8().data() );
}
}
if(status.pause && icon_type==1)
{
icon_type=3;
}
if(icon_type!=last_icon_type || last_status!=status_text)
{
last_status=status_text;
switch(icon_type)
{
case 0:
if(tray!=NULL)
tray->SetIcon(wxIcon(wxT("backup-ok.ico"), wxBITMAP_TYPE_ICO), status_text);
if(timer!=NULL)
timer->Start(60000);
break;
case 1:
if(tray!=NULL)
tray->SetIcon(wxIcon(wxT("backup-progress.ico"), wxBITMAP_TYPE_ICO), status_text);
if(timer!=NULL)
timer->Start(10000);
break;
case 2:
if(tray!=NULL)
tray->SetIcon(wxIcon(wxT("backup-bad.ico"), wxBITMAP_TYPE_ICO), status_text);
if(timer!=NULL)
timer->Start(60000);
break;
case 3:
if(tray!=NULL)
tray->SetIcon(wxIcon(wxT("backup-progress-pause.ico"), wxBITMAP_TYPE_ICO), status_text);
if(timer!=NULL)
timer->Start(60000);
}
}
working=false;
}
#ifndef DD_RELEASE
int main(int argc, char *argv[])
{
wxEntry(argc, argv);
}
#else
IMPLEMENT_APP(MyApp)
#endif

37
main.h Normal file
View File

@ -0,0 +1,37 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include <wx/wx.h>
#include <wx/timer.h>
#include <wx/intl.h>
class MyApp : public wxApp
{
public:
virtual bool OnInit();
virtual int OnExit();
private:
wxLocale m_locale;
};
class MyTimer : public wxTimer
{
public:
void Notify(void);
};

16
resource.h Normal file
View File

@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by UrBackupClientGUI.rc
//
#define IDI_ICON1 101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

1387
stringtools.cpp Normal file

File diff suppressed because it is too large Load Diff

109
stringtools.h Normal file
View File

@ -0,0 +1,109 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#ifndef STRINGTOOLS_H
#define STRINGTOOLS_H
#include <string>
#include <vector>
#include <map>
std::string getafter(const std::string &str,const std::string &data);
std::string getafterinc(const std::string &str,const std::string &data);
std::wstring getafter(const std::wstring &str,const std::wstring &data);
std::wstring getafterinc(const std::wstring &str,const std::wstring &data);
std::string getbetween(std::string s1,std::string s2,std::string data);
std::string strdelete(std::string str,std::string data);
void writestring(std::string str,std::string file);
void writestring(char *str, unsigned int len,std::string file);
std::string getuntil(std::string str,std::string data);
std::wstring getuntil(std::wstring str,std::wstring data);
std::string getuntilinc(std::string str,std::string data);
std::string getline(int line, const std::string &str);
int linecount(const std::string &str);
std::string getFile(std::string filename);
std::wstring getFileUTF8(std::string filename);
std::string ExtractFileName(std::string fulln);
std::string ExtractFilePath(std::string fulln);
std::wstring ExtractFilePath(std::wstring fulln);
std::wstring convert(bool pBool);
std::wstring convert(int i);
std::wstring convert(float f);
std::wstring convert(long long int i);
std::wstring convert(size_t i);
std::wstring convert(unsigned long long int i);
std::wstring convert(unsigned int i);
std::string nconvert(bool pBool);
std::string nconvert(int i);
std::string nconvert(long long int i);
std::string nconvert(size_t i);
std::string nconvert(unsigned long long int i);
std::string nconvert(unsigned int i);
std::string nconvert(float f);
std::string findextension(const std::string& pString);
std::string wnarrow(const std::wstring& pStr);
std::wstring widen(std::string tw);
std::string replaceonce(std::string tor, std::string tin, std::string data);
std::wstring replaceonce(std::wstring tor, std::wstring tin, std::wstring data);
void Tokenize(std::string& str, std::vector<std::string> &tokens, std::string seps);
void Tokenize(std::wstring& str, std::vector<std::wstring> &tokens, std::wstring seps);
void TokenizeMail(std::string& str, std::vector<std::string> &tokens, std::string seps);
bool isnumber(char ch);
bool isletter(char ch);
bool isnumber(wchar_t ch);
bool isletter(wchar_t ch);
void strupper(std::string *pStr);
void strupper(std::wstring *pStr);
std::string greplace(std::string tor, std::string tin, std::string data);
std::wstring greplace(std::wstring tor, std::wstring tin, std::wstring data);
int getNextNumber(const std::string &pStr, int *read=NULL);
std::string strlower(const std::string &str);
bool next(const std::string &pData, const size_t & doff, const std::string &pStr);
bool next(const std::wstring &pData, const size_t & doff, const std::wstring &pStr);
char getRandomChar(void);
std::string getRandomNumber(void);
void transformHTML(std::string &str);
void EscapeSQLString(std::string &pStr);
void EscapeSQLString(std::wstring &pStr);
void EscapeCh(std::string &pStr, char ch='\\');
void EscapeCh(std::wstring &pStr, wchar_t ch);
std::string UnescapeSQLString(std::string pStr);
std::wstring UnescapeSQLString(std::wstring pStr);
void ParseParamStr(const std::string &pStr, std::map<std::wstring,std::wstring> *pMap);
int round(float f);
std::string FormatTime(int timeins);
bool IsHex(const std::string &str);
unsigned long hexToULong(const std::string &data);
std::wstring htmldecode(std::string str, bool html=true, char xc='%');
bool checkhtml(const std::string &str);
std::string nl2br(std::string str);
bool FileExists(std::string pFile);
bool checkStringHTML(const std::string &str);
std::string ReplaceChar(std::string str, char tr, char ch);
std::wstring ReplaceChar(std::wstring str, wchar_t tr, wchar_t ch);
std::string striptags(std::string html);
std::string base64_encode(unsigned char const* , unsigned int len);
std::string base64_decode(std::string const& s);
bool CheckForIllegalChars(const std::string &str);
int watoi(std::wstring str);
std::wstring strlower(const std::wstring &str);
std::string trim(const std::string &str);
void replaceNonAlphaNumeric(std::string &str, char rch);
std::string conv_filename(std::string fn);
#endif

90
tcpstack.cpp Normal file
View File

@ -0,0 +1,90 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "tcpstack.h"
#include <memory.h>
void CTCPStack::AddData(char* buf, size_t datasize)
{
if(datasize>0)
{
size_t osize=buffer.size();
buffer.resize(osize+datasize);
memcpy(&buffer[osize], buf, datasize);
}
}
size_t CTCPStack::Send(wxSocketBase* p, char* buf, size_t msglen)
{
char* buffer=new char[msglen+sizeof(MAX_PACKETSIZE)];
MAX_PACKETSIZE len=(MAX_PACKETSIZE)msglen;
memcpy(buffer, &len, sizeof(MAX_PACKETSIZE) );
memcpy(&buffer[sizeof(MAX_PACKETSIZE)], buf, msglen);
p->Write(buffer, msglen+sizeof(MAX_PACKETSIZE));
delete[] buffer;
return msglen;
}
size_t CTCPStack::Send(wxSocketBase* p, const std::string &msg)
{
return Send(p, (char*)msg.c_str(), msg.size());
}
char* CTCPStack::getPacket(size_t* packetsize)
{
if(buffer.size()>1)
{
MAX_PACKETSIZE len;
memcpy(&len, &buffer[0], sizeof(MAX_PACKETSIZE) );
if(len==0)
{
*packetsize=0;
buffer.erase(buffer.begin(), buffer.begin()+len+sizeof(MAX_PACKETSIZE));
return NULL;
}
if(buffer.size()>=(size_t)len+sizeof(MAX_PACKETSIZE))
{
char* buf=new char[len+1];
memcpy(buf, &buffer[sizeof(MAX_PACKETSIZE)], len);
(*packetsize)=len;
buffer.erase(buffer.begin(), buffer.begin()+len+sizeof(MAX_PACKETSIZE));
buf[len]=0;
return buf;
}
}
*packetsize=-1;
return NULL;
}
void CTCPStack::reset(void)
{
buffer.clear();
}

47
tcpstack.h Normal file
View File

@ -0,0 +1,47 @@
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#ifndef TCPSTACK_H
#define TCPSTACK_H
#include <vector>
#include <wx/wx.h>
#include <wx/socket.h>
#define MAX_PACKETSIZE unsigned int
class CWData;
class CTCPStack
{
public:
void AddData(char* buf, size_t datasize);
char* getPacket(size_t* packsize);
size_t Send(wxSocketBase* p, char* buf, size_t msglen);
size_t Send(wxSocketBase* p, const std::string &msg);
void reset(void);
private:
std::vector<char> buffer;
};
#endif //TCPSTACK_H

BIN
trans.mo Normal file

Binary file not shown.

285
trans.po Normal file
View File

@ -0,0 +1,285 @@
# UrBackup English translation
# Copyright (C) 2011 Martin Raiber
# This file is distributed under the same license as the UrBackup package.
# Martin Raiber <urpc@gmx.de>, 2011.
#
msgid ""
msgstr ""
"Project-Id-Version: UrBackup 0.34\n"
"Report-Msgid-Bugs-To: urpc@gmx.de\n"
"POT-Creation-Date: 2011-01-05 13:53+0100\n"
"PO-Revision-Date: 2011-01-16 19:43+0100\n"
"Last-Translator: Martin Raiber <urpc@gmx.de>\n"
"Language-Team: ENGLISH <urpc@gmx.de>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: gui/GUI.cpp:26
msgid "Intervall für inkrementelle Backups:"
msgstr "Interval for incremental file backups:"
#: gui/GUI.cpp:30
msgid "Intervall für volle Backups:"
msgstr "Interval for full file backups:"
#: gui/GUI.cpp:34
msgid "Intervall für inkrementelle Image-Backups:"
msgstr "Interval for incremental image backups:"
#: gui/GUI.cpp:38
msgid "Intervall für volle Image-Backups:"
msgstr "Interval for full image backups:"
#: gui/GUI.cpp:46
msgid "Minimale Anzahl an inkrementellen Backups:"
msgstr "Minimal number of incremental file backups:"
#: gui/GUI.cpp:50
msgid "Maximale Anzahl an inkrementellen Backups:"
msgstr "Maximal number of incremental file backups:"
#: gui/GUI.cpp:54
msgid "Minimale Anzahl an vollen Backups:"
msgstr "Minimal number of full file backups:"
#: gui/GUI.cpp:58
msgid "Maximale Anzahl an vollen Backups:"
msgstr "Maximal number of full file backups:"
#: gui/GUI.cpp:66
msgid "Minimale Anzahl an inkrementellen Image-Backups:"
msgstr "Minimal number of incremental image backups:"
#: gui/GUI.cpp:70
msgid "Maximale Anzahl an inkrementellen Image-Backups:"
msgstr "Maximal number of incremental image backups:"
#: gui/GUI.cpp:74
msgid "Minimale Anzahl an vollen Image-Backups:"
msgstr "Minimal number of full image backups:"
#: gui/GUI.cpp:78
msgid "Maximale Anzahl an vollen Image-Backups:"
msgstr "Maximal number of full image backups:"
#: gui/GUI.cpp:93
msgid "Stunden"
msgstr "hours"
#: gui/GUI.cpp:105
#: gui/GUI.cpp:117
#: gui/GUI.cpp:137
msgid "Tage"
msgstr "days"
#: gui/GUI.cpp:124
msgid "Aktiv"
msgstr "Active"
#: gui/GUI.cpp:232
#: gui/GUI.cpp:389
msgid "OK"
msgstr "Ok"
#: gui/GUI.cpp:237
#: ConfigPath.cpp:13
msgid "Abbrechen"
msgstr "Abort"
#: gui/GUI.cpp:282
msgid "Filter:"
msgstr "Filter:"
#: gui/GUI.cpp:286
#: TrayIcon.cpp:119
msgid "Info"
msgstr "Infos"
#: gui/GUI.cpp:286
msgid "Warnings"
msgstr "Warnings"
#: gui/GUI.cpp:286
msgid "Errors"
msgstr "Errors"
#: gui/GUI.cpp:303
msgid "Verlassen"
msgstr "Exit"
#: gui/GUI.cpp:356
msgid "Version:"
msgstr "Version:"
#: gui/GUI.cpp:368
msgid "Autor:"
msgstr "Author:"
#: ConfigPath.cpp:6
msgid "Pfade hinzufügen und entfernen"
msgstr "Remove/Add backup paths"
#: ConfigPath.cpp:12
msgid "Ok"
msgstr "Ok"
#: ConfigPath.cpp:14
msgid "Neuer Pfad"
msgstr "Add path"
#: ConfigPath.cpp:15
msgid "Pfad entfernen"
msgstr "Remove path"
#: ConfigPath.cpp:26
#: Logs.cpp:10
msgid "Ein Fehler ist aufgetreten. Backups werden momentan nicht durchgeführt."
msgstr "There was an error. Currently nothing can be backed up."
#: ConfigPath.cpp:54
msgid "Bitte Verzeichnis das gesichert werden soll auswählen"
msgstr "Please select the directory that will be backed up."
#: main.cpp:125
msgid "UrBackup: Update verfügbar"
msgstr "UrBackup: Update available"
#: main.cpp:125
msgid "Eine neue Version von UrBackup ist verfügbar. Klicken Sie hier um diese zu installieren"
msgstr "A new version of UrBackup is available. Please click here to install it now."
#: main.cpp:143
msgid "Keine Verbindung zum Backupserver möglich"
msgstr "Cannot connect to backup server"
#: main.cpp:163
msgid "Inkrementelles Backup läuft. "
msgstr "Incremental file backup running."
#: main.cpp:175
msgid "Volles Backup läuft. "
msgstr "Full file backup running."
#: main.cpp:186
msgid "Inkrementelles Image-Backup läuft. "
msgstr "Incremental image backup running."
#: main.cpp:197
msgid "Volles Image-Backup läuft. "
msgstr "Full image backup running."
#: main.cpp:208
msgid "Kein aktuelles Backup. "
msgstr "No current backup."
#: main.cpp:219
msgid "Letztes Backup am "
msgstr "Last backup on "
#: Settings.cpp:156
msgid "Die inkrementelle Backupzeit ist keine Zahl"
msgstr "The incremental backup interval is not a number"
#: Settings.cpp:162
msgid "Die volle Backupzeit ist keine Zahl"
msgstr "The full backup interval is not a number"
#: Settings.cpp:168
msgid "Die volle Imagebackupzeit ist keine Zahl"
msgstr "The full image backup interval is not a number"
#: Settings.cpp:174
msgid "Die inkrementelle Imagebackupzeit ist keine Zahl"
msgstr "The incremental image backup time is not a number"
#: Settings.cpp:180
msgid "Die maximale Anzahl an inkrementellen Backups ist keine Zahl"
msgstr "The maximal number of incremental file backups is not a number"
#: Settings.cpp:186
msgid "Die minimale Anzahl an inkrementellen Backups ist keine Zahl"
msgstr "The minimal number of incremental file backups is not a number"
#: Settings.cpp:192
msgid "Die maximale Anzahl an vollen Backups ist keine Zahl"
msgstr "The maximal number of full file backups is not a number"
#: Settings.cpp:198
msgid "Die minimale Anzahl an vollen Backups ist keine Zahl"
msgstr "Minimal number of full file backups is not a number"
#: Settings.cpp:204
msgid "Die minimale Anzahl an inkrementellen Image-Backups ist keine Zahl"
msgstr "Minimal number of incremental image backups is not a number"
#: Settings.cpp:210
msgid "Die maximale Anzahl an inkrementellen Image-Backups ist keine Zahl"
msgstr "Maximal number of incremental image backups is not a number"
#: Settings.cpp:216
msgid "Die minimale Anzahl an vollen Image-Backups ist keine Zahl"
msgstr "Minimal number of full image backups is not a number"
#: Settings.cpp:222
msgid "Die maximale Anzahl an vollen Image-Backups ist keine Zahl"
msgstr "Maximal number of full image backups is not a number"
#: TrayIcon.cpp:49
#: TrayIcon.cpp:72
msgid "Ein Backup läuft bereits. Konnte leider kein weiteres starten."
msgstr "A backup is already running. Could not start another one."
#: TrayIcon.cpp:51
#: TrayIcon.cpp:74
msgid "Konnte kein Backup starten, da leider kein Server gefunden wurde"
msgstr "Could not start backup, because no backup server was found."
#: TrayIcon.cpp:86
msgid "Verbindung mit Backupserver fehlgeschlagen. Konnte nicht pausieren."
msgstr "Pausing failed: No connection to backup server."
#: TrayIcon.cpp:99
msgid "Verbindung mit Backupserver fehlgeschlagen. Konnte nicht fortfahren."
msgstr "Continuing failed: No connection to backup server."
#: TrayIcon.cpp:111
msgid "Volles Backup jetzt"
msgstr "Do full file backup"
#: TrayIcon.cpp:112
msgid "Inkremetelles Backup jetzt"
msgstr "Do incremental file backup"
#: TrayIcon.cpp:113
msgid "Volles Image-Backup jetzt"
msgstr "Do full image backup"
#: TrayIcon.cpp:114
msgid "Inkremetelles Image-Backup jetzt"
msgstr "Do incremental image backup"
#: TrayIcon.cpp:116
msgid "Einstellungen"
msgstr "Settings"
#: TrayIcon.cpp:117
msgid "Pfade konfigurieren"
msgstr "Add/Remove backup paths"
#: TrayIcon.cpp:118
msgid "Logs"
msgstr "Logs"
#: TrayIcon.cpp:124
msgid "Pausieren"
msgstr "Pause"
#: TrayIcon.cpp:128
msgid "Fortfahren"
msgstr "Continue"
#: Gui.h:144
msgid "Informationen"
msgstr "Informations"

274
urbackup.nsi Normal file
View File

@ -0,0 +1,274 @@
!define MUI_BRANDINGTEXT "UrBackup 0.35"
!include "${NSISDIR}\Contrib\Modern UI\System.nsh"
!include WinVer.nsh
!include "x64.nsh"
!define MUI_ICON "backup-ok.ico"
SetCompressor /FINAL /SOLID lzma
CRCCheck On
Name "UrBackup 0.35"
OutFile "UrBackup Client 0.35-1.exe"
InstallDir "$PROGRAMFILES\UrBackup"
RequestExecutionLevel highest
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!define MUI_LANGDLL_ALLLANGUAGES
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY "Software\UrBackup"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
!define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_RESERVEFILE_LANGDLL
Section "install"
${If} ${RunningX64}
!insertmacro DisableX64FSRedirection
SetRegView 64
${EndIf}
${If} ${RunningX64}
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\10.0\VC\Runtimes\x64" 'Installed'
${If} $0 != '1'
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x64" 'Installed'
${If} $0 != '1'
inetc::get "http://www.urserver.de/vc10/vcredist_x64.exe" $TEMP\vcredist_x64.exe
Pop $0
ExecWait '"$TEMP\vcredist_x64.exe" /q'
Delete '$TEMP\vcredist_x64.exe'
${EndIf}
${EndIf}
${Else}
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\10.0\VC\Runtimes\x86" 'Installed'
${If} $0 != '1'
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x86" 'Installed'
${If} $0 != '1'
inetc::get "http://www.urserver.de/vc10/vcredist_x86.exe" $TEMP\vcredist_x86.exe
Pop $0
ExecWait '"$TEMP\vcredist_x86.exe" /q'
Delete '$TEMP\vcredist_x86.exe'
${EndIf}
${EndIf}
${EndIf}
StrCpy $0 "UrBackupClient.exe"
KillProc::KillProcesses
${If} ${RunningX64}
File "data_x64\KillProc.exe"
ExecWait '"$INSTDIR\KillProc.exe" UrBackupClient.exe'
${EndIf}
SimpleSC::ExistsService "UrBackupServer"
Pop $0
${If} $0 == '0'
SimpleSC::StopService "UrBackupServer"
Pop $0
${EndIf}
;SimpleSC::RemoveService "UrBackupServer"
;Pop $0
SetOutPath "$INSTDIR"
Sleep 500
WriteUninstaller "$INSTDIR\Uninstall.exe"
CreateDirectory "$SMPROGRAMS\UrBackup"
CreateShortCut "$SMPROGRAMS\UrBackup\Uninstall.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\UrBackup\UrBackup.lnk" "$INSTDIR\UrBackupClient.exe" "" "$INSTDIR\UrBackupClient.exe" 0
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UrBackup" "DisplayName" "UrBackup (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UrBackup" "UninstallString" "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UrBackup" "Path" "$INSTDIR"
File "data\args.txt"
${IfNot} ${RunningX64}
File "data\args_server03.txt"
File "data\args_xp.txt"
File "data\fileservplugin.dll"
File "data\fsimageplugin.dll"
File "data\urbackup.dll"
File "data\urbackup_server03.dll"
File "data\urbackup_xp.dll"
File "data\UrBackupClient.exe"
File "data\urbackupsrv.exe"
File "data\cryptoplugin.dll"
${Else}
File "data\args_server03.txt"
File "data_x64\urbackup_server03.dll"
File "data_x64\fileservplugin.dll"
File "data_x64\fsimageplugin.dll"
File "data_x64\urbackup.dll"
File "data_x64\UrBackupClient.exe"
File "data_x64\urbackupsrv.exe"
File "data_x64\cryptoplugin.dll"
${EndIf}
File "data\backup-bad.ico"
File "data\backup-ok.ico"
File "data\backup-ok-big.ico"
File "data\backup-progress.ico"
File "data\new.txt"
File "data\logo1.png"
File "data\backup-progress-pause.ico"
File "data\urbackup_dsa.pub"
File "data\curr_version.txt"
File "data\updates_h.dat"
File "data\license.txt"
SetOutPath "$INSTDIR\en"
File "data\en\trans.mo"
SetOutPath "$INSTDIR\urbackup"
File "data\urbackup\backup_client_new.db"
CreateDirectory "$INSTDIR\urbackup\data"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "UrBackupClient" "$INSTDIR\UrBackupClient.exe"
${IfNot} ${RunningX64}
${If} ${IsWinXP}
StrCpy $0 "$INSTDIR\args_xp.txt" ;Path of copy file from
StrCpy $1 "$INSTDIR\args.txt" ;Path of copy file to
StrCpy $2 0 ; only 0 or 1, set 0 to overwrite file if it already exists
System::Call 'kernel32::CopyFile(t r0, t r1, b r2) l'
Pop $0
;SetRebootFlag true
${EndIf}
${If} ${IsWin2003}
StrCpy $0 "$INSTDIR\args_server03.txt" ;Path of copy file from
StrCpy $1 "$INSTDIR\args.txt" ;Path of copy file to
StrCpy $2 0 ; only 0 or 1, set 0 to overwrite file if it already exists
System::Call 'kernel32::CopyFile(t r0, t r1, b r2) l'
Pop $0
;SetRebootFlag true
${EndIf}
${Else}
${If} ${IsWin2003}
StrCpy $0 "$INSTDIR\args_server03.txt" ;Path of copy file from
StrCpy $1 "$INSTDIR\args.txt" ;Path of copy file to
StrCpy $2 0 ; only 0 or 1, set 0 to overwrite file if it already exists
System::Call 'kernel32::CopyFile(t r0, t r1, b r2) l'
Pop $0
;SetRebootFlag true
${EndIf}
${EndIf}
IfFileExists "$INSTDIR\urbackup\backup_client.db" next_s do_copy
do_copy:
StrCpy $0 "$INSTDIR\urbackup\backup_client_new.db" ;Path of copy file from
StrCpy $1 "$INSTDIR\urbackup\backup_client.db" ;Path of copy file to
StrCpy $2 0 ; only 0 or 1, set 0 to overwrite file if it already exists
System::Call 'kernel32::CopyFile(t r0, t r1, b r2) l'
Pop $0
next_s:
Delete "$INSTDIR\urbackup\backup_client_new.db"
nsisFirewall::AddAuthorizedApplication "$INSTDIR\urbackupsrv.exe" "UrBackup Server"
Pop $0
SimpleSC::ExistsService "UrBackupServer"
Pop $0
${If} $0 != '0'
SimpleSC::InstallService "UrBackupServer" "UrBackup Server for doing backups" "16" "2" "$INSTDIR\urbackupsrv.exe" "" "" ""
Pop $0
${EndIf}
SimpleSC::StartService "UrBackupServer" ""
Pop $0
${If} ${RunningX64}
!insertmacro EnableX64FSRedirection
SetRegView 32
${EndIf}
SectionEnd
Section "Uninstall"
${If} ${RunningX64}
!insertmacro DisableX64FSRedirection
SetRegView 64
${EndIf}
StrCpy $0 "UrBackupClient.exe"
KillProc::KillProcesses
${If} ${RunningX64}
File "data_x64\KillProc.exe"
ExecWait '"$INSTDIR\KillProc.exe" UrBackupClient.exe'
${EndIf}
SimpleSC::StopService "UrBackupServer"
Pop $0
SimpleSC::RemoveService "UrBackupServer"
Pop $0
Sleep 500
RMDir /r "$INSTDIR\*.*"
RMDir "$INSTDIR"
Delete "$SMPROGRAMS\UrBackup\*.*"
RMDir "$SMPROGRAMS\UrBackup"
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\UrBackup"
DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "UrBackupClient"
${If} ${RunningX64}
!insertmacro EnableX64FSRedirection
SetRegView 32
${EndIf}
DeleteRegKey /ifempty HKCU "Software\UrBackup"
SectionEnd
Function .onInstSuccess
${If} ${RunningX64}
!insertmacro DisableX64FSRedirection
SetRegView 64
${EndIf}
Exec "$INSTDIR\UrBackupClient.exe"
${If} ${RunningX64}
!insertmacro EnableX64FSRedirection
SetRegView 32
${EndIf}
FunctionEnd
Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
FunctionEnd
Function un.onUninstSuccess
MessageBox MB_OK "UrBackup wurde erfolgreich deinstalliert."
FunctionEnd
Function myGuiInit
;MessageBox MB_OK "blub"
;${If} ${RunningX64}
; !insertmacro DisableX64FSRedirection
; SetRegView 64
;${EndIf}
FunctionEnd
Function .onInit
${If} ${RunningX64}
strcpy $INSTDIR "$PROGRAMFILES64\UrBackup"
${EndIf}
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd

258
urbackup_update.nsi Normal file
View File

@ -0,0 +1,258 @@
!define MUI_BRANDINGTEXT "UrBackup Update 0.35"
!include "${NSISDIR}\Contrib\Modern UI\System.nsh"
!include WinVer.nsh
!include "x64.nsh"
!define MUI_ICON "backup-ok.ico"
SetCompressor /FINAL /SOLID lzma
CRCCheck On
Name "UrBackup Update"
OutFile "UrBackupUpdate.exe"
InstallDir "$PROGRAMFILES\UrBackup"
RequestExecutionLevel highest
!insertmacro MUI_PAGE_INSTFILES
!define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit
!insertmacro MUI_LANGUAGE "English"
Section "install"
${If} ${RunningX64}
!insertmacro DisableX64FSRedirection
SetRegView 64
${EndIf}
${If} ${RunningX64}
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\10.0\VC\Runtimes\x64" 'Installed'
${If} $0 != '1'
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x64" 'Installed'
${If} $0 != '1'
inetc::get "http://www.urserver.de/vc10/vcredist_x64.exe" $TEMP\vcredist_x64.exe
Pop $0
ExecWait '"$TEMP\vcredist_x64.exe" /q'
Delete '$TEMP\vcredist_x64.exe'
${EndIf}
${EndIf}
${Else}
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\10.0\VC\Runtimes\x86" 'Installed'
${If} $0 != '1'
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x86" 'Installed'
${If} $0 != '1'
inetc::get "http://www.urserver.de/vc10/vcredist_x86.exe" $TEMP\vcredist_x86.exe
Pop $0
ExecWait '"$TEMP\vcredist_x86.exe" /q'
Delete '$TEMP\vcredist_x86.exe'
${EndIf}
${EndIf}
${EndIf}
StrCpy $0 "UrBackupClient.exe"
KillProc::KillProcesses
${If} ${RunningX64}
File "data_x64\KillProc.exe"
ExecWait '"$INSTDIR\KillProc.exe" UrBackupClient.exe'
${EndIf}
SimpleSC::ExistsService "UrBackupServer"
Pop $0
${If} $0 == '0'
SimpleSC::StopService "UrBackupServer"
Pop $0
${EndIf}
;SimpleSC::RemoveService "UrBackupServer"
;Pop $0
SetOutPath "$INSTDIR"
Sleep 500
WriteUninstaller "$INSTDIR\Uninstall.exe"
CreateDirectory "$SMPROGRAMS\UrBackup"
CreateShortCut "$SMPROGRAMS\UrBackup\Uninstall.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\UrBackup\UrBackup.lnk" "$INSTDIR\UrBackupClient.exe" "" "$INSTDIR\UrBackupClient.exe" 0
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UrBackup" "DisplayName" "UrBackup (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UrBackup" "UninstallString" "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UrBackup" "Path" "$INSTDIR"
File "data\args.txt"
${IfNot} ${RunningX64}
File "data\args_server03.txt"
File "data\args_xp.txt"
File "data\fileservplugin.dll"
File "data\fsimageplugin.dll"
File "data\urbackup.dll"
File "data\urbackup_server03.dll"
File "data\urbackup_xp.dll"
File "data\UrBackupClient.exe"
File "data\urbackupsrv.exe"
File "data\cryptoplugin.dll"
${Else}
File "data\args_server03.txt"
File "data_x64\urbackup_server03.dll"
File "data_x64\fileservplugin.dll"
File "data_x64\fsimageplugin.dll"
File "data_x64\urbackup.dll"
File "data_x64\UrBackupClient.exe"
File "data_x64\urbackupsrv.exe"
File "data_x64\cryptoplugin.dll"
${EndIf}
File "data\backup-bad.ico"
File "data\backup-ok.ico"
File "data\backup-ok-big.ico"
File "data\backup-progress.ico"
File "data\new.txt"
File "data\logo1.png"
File "data\backup-progress-pause.ico"
File "data\urbackup_dsa.pub"
File "data\curr_version.txt"
File "data\updates_h.dat"
File "data\license.txt"
SetOutPath "$INSTDIR\en"
File "data\en\trans.mo"
SetOutPath "$INSTDIR\urbackup"
File "data\urbackup\backup_client_new.db"
CreateDirectory "$INSTDIR\urbackup\data"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "UrBackupClient" "$INSTDIR\UrBackupClient.exe"
${IfNot} ${RunningX64}
${If} ${IsWinXP}
StrCpy $0 "$INSTDIR\args_xp.txt" ;Path of copy file from
StrCpy $1 "$INSTDIR\args.txt" ;Path of copy file to
StrCpy $2 0 ; only 0 or 1, set 0 to overwrite file if it already exists
System::Call 'kernel32::CopyFile(t r0, t r1, b r2) l'
Pop $0
;SetRebootFlag true
${EndIf}
${If} ${IsWin2003}
StrCpy $0 "$INSTDIR\args_server03.txt" ;Path of copy file from
StrCpy $1 "$INSTDIR\args.txt" ;Path of copy file to
StrCpy $2 0 ; only 0 or 1, set 0 to overwrite file if it already exists
System::Call 'kernel32::CopyFile(t r0, t r1, b r2) l'
Pop $0
;SetRebootFlag true
${EndIf}
${Else}
${If} ${IsWin2003}
StrCpy $0 "$INSTDIR\args_server03.txt" ;Path of copy file from
StrCpy $1 "$INSTDIR\args.txt" ;Path of copy file to
StrCpy $2 0 ; only 0 or 1, set 0 to overwrite file if it already exists
System::Call 'kernel32::CopyFile(t r0, t r1, b r2) l'
Pop $0
;SetRebootFlag true
${EndIf}
${EndIf}
IfFileExists "$INSTDIR\urbackup\backup_client.db" next_s do_copy
do_copy:
StrCpy $0 "$INSTDIR\urbackup\backup_client_new.db" ;Path of copy file from
StrCpy $1 "$INSTDIR\urbackup\backup_client.db" ;Path of copy file to
StrCpy $2 0 ; only 0 or 1, set 0 to overwrite file if it already exists
System::Call 'kernel32::CopyFile(t r0, t r1, b r2) l'
Pop $0
next_s:
Delete "$INSTDIR\urbackup\backup_client_new.db"
nsisFirewall::AddAuthorizedApplication "$INSTDIR\urbackupsrv.exe" "UrBackup Server"
Pop $0
SimpleSC::ExistsService "UrBackupServer"
Pop $0
${If} $0 != '0'
SimpleSC::InstallService "UrBackupServer" "UrBackup Server for doing backups" "16" "2" "$INSTDIR\urbackupsrv.exe" "" "" ""
Pop $0
${EndIf}
SimpleSC::StartService "UrBackupServer" ""
Pop $0
${If} ${RunningX64}
!insertmacro EnableX64FSRedirection
SetRegView 32
${EndIf}
SectionEnd
Section "Uninstall"
${If} ${RunningX64}
!insertmacro DisableX64FSRedirection
SetRegView 64
${EndIf}
StrCpy $0 "UrBackupClient.exe"
KillProc::KillProcesses
${If} ${RunningX64}
File "data_x64\KillProc.exe"
ExecWait '"$INSTDIR\KillProc.exe" UrBackupClient.exe'
${EndIf}
SimpleSC::StopService "UrBackupServer"
Pop $0
SimpleSC::RemoveService "UrBackupServer"
Pop $0
Sleep 500
RMDir /r "$INSTDIR\*.*"
RMDir "$INSTDIR"
Delete "$SMPROGRAMS\UrBackup\*.*"
RMDir "$SMPROGRAMS\UrBackup"
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\UrBackup"
DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "UrBackupClient"
${If} ${RunningX64}
!insertmacro EnableX64FSRedirection
SetRegView 32
${EndIf}
SectionEnd
Function .onInstSuccess
${If} ${RunningX64}
!insertmacro DisableX64FSRedirection
SetRegView 64
${EndIf}
Exec "$INSTDIR\UrBackupClient.exe"
${If} ${RunningX64}
!insertmacro EnableX64FSRedirection
SetRegView 32
${EndIf}
FunctionEnd
Function un.onUninstSuccess
MessageBox MB_OK "UrBackup wurde erfolgreich deinstalliert."
FunctionEnd
Function myGuiInit
;MessageBox MB_OK "blub"
;${If} ${RunningX64}
; !insertmacro DisableX64FSRedirection
; SetRegView 64
;${EndIf}
FunctionEnd
Function .onInit
${If} ${RunningX64}
strcpy $INSTDIR "$PROGRAMFILES64\UrBackup"
SetRegView 64
${EndIf}
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UrBackup" 'Path'
strcpy $INSTDIR $0
${If} ${RunningX64}
SetRegView 32
${EndIf}
FunctionEnd

144
urbackup_x64.nsi Normal file
View File

@ -0,0 +1,144 @@
!define MUI_BRANDINGTEXT "UrBackup 0.22"
!include "${NSISDIR}\Contrib\Modern UI\System.nsh"
!include WinVer.nsh
!include "x64.nsh"
!define MUI_ICON "backup-ok.ico"
SetCompressor /FINAL /SOLID lzma
CRCCheck On
Name "UrBackup 0.22"
OutFile "UrBackup Client 0.22-1-x64.exe"
InstallDir "$PROGRAMFILES\UrBackup"
RequestExecutionLevel highest
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "German"
Section "install"
${IfNot} ${RunningX64}
MessageBox MB_OK "Dies ist die Installationsdatei fuer das 64Bit Betriebssystem. Das momentane Betriebssystem ist nicht 64-bittig. Benutzen sie die andere Installationsdatei."
Abort "Falsche Installationsdatei"
${EndIf}
!insertmacro DisableX64FSRedirection
SetRegView 64
StrCpy $0 "UrBackupClient.exe"
KillProc::KillProcesses
SimpleSC::StopService "UrBackupServer"
Pop $0
SimpleSC::RemoveService "UrBackupServer"
Pop $0
SetOutPath "$INSTDIR"
WriteUninstaller "$INSTDIR\Uninstall.exe"
CreateDirectory "$SMPROGRAMS\UrBackup"
CreateShortCut "$SMPROGRAMS\UrBackup\Uninstall.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\UrBackup\UrBackup.lnk" "$INSTDIR\UrBackupClient.exe" "" "$INSTDIR\UrBackupClient.exe" 0
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UrBackup" "DisplayName" "UrBackup (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UrBackup" "UninstallString" "$INSTDIR\Uninstall.exe"
File "data\args.txt"
File "data\backup-bad.ico"
File "data\backup-ok.ico"
File "data\backup-ok-big.ico"
File "data\backup-progress.ico"
File "data_x64\fileservplugin.dll"
File "data_x64\fsimageplugin.dll"
File "data\new.txt"
File "data_x64\urbackup.dll"
File "data_x64\UrBackupClient.exe"
File "data_x64\urbackupsrv.exe"
File "data\logo1.png"
File "data\backup-progress-pause.ico"
SetOutPath "$INSTDIR\urbackup"
File "data\urbackup\backup_client_new.db"
CreateDirectory "$INSTDIR\urbackup\data"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "UrBackupClient" "$INSTDIR\UrBackupClient.exe"
;${If} ${IsWinXP}
; StrCpy $0 "$INSTDIR\args_xp.txt" ;Path of copy file from
; StrCpy $1 "$INSTDIR\args.txt" ;Path of copy file to
; StrCpy $2 0 ; only 0 or 1, set 0 to overwrite file if it already exists
; System::Call 'kernel32::CopyFile(t r0, t r1, b r2) l'
; Pop $0
;${EndIf}
;${If} ${IsWin2003}
; StrCpy $0 "$INSTDIR\args_server03.txt" ;Path of copy file from
; StrCpy $1 "$INSTDIR\args.txt" ;Path of copy file to
; StrCpy $2 0 ; only 0 or 1, set 0 to overwrite file if it already exists
; System::Call 'kernel32::CopyFile(t r0, t r1, b r2) l'
; Pop $0
;${EndIf}
IfFileExists "$INSTDIR\urbackup\backup_client.db" next_s do_copy
do_copy:
StrCpy $0 "$INSTDIR\urbackup\backup_client_new.db" ;Path of copy file from
StrCpy $1 "$INSTDIR\urbackup\backup_client.db" ;Path of copy file to
StrCpy $2 0 ; only 0 or 1, set 0 to overwrite file if it already exists
System::Call 'kernel32::CopyFile(t r0, t r1, b r2) l'
Pop $0
next_s:
Delete "$INSTDIR\urbackup\backup_client_new.db"
nsisFirewall::AddAuthorizedApplication "$INSTDIR\urbackupsrv.exe" "UrBackup Server"
Pop $0
SimpleSC::InstallService "UrBackupServer" "UrBackup Server for doing backups" "16" "2" "$INSTDIR\urbackupsrv.exe" "" "" ""
Pop $0
SimpleSC::StartService "UrBackupServer" ""
Pop $0
SectionEnd
Section "Uninstall"
!insertmacro DisableX64FSRedirection
SetRegView 64
StrCpy $0 "UrBackupClient.exe"
KillProc::KillProcesses
SimpleSC::StopService "UrBackupServer"
Pop $0
SimpleSC::RemoveService "UrBackupServer"
Pop $0
RMDir /r "$INSTDIR\*.*"
RMDir "$INSTDIR"
Delete "$SMPROGRAMS\UrBackup\*.*"
RMDir "$SMPROGRAMS\UrBackup"
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\UrBackup"
DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "UrBackupClient"
SectionEnd
Function .onInstSuccess
Exec "$INSTDIR\UrBackupClient.exe"
FunctionEnd
Function un.onUninstSuccess
MessageBox MB_OK "UrBackup wurde erfolgreich deinstalliert."
FunctionEnd

34
utf8/utf8.h Normal file
View File

@ -0,0 +1,34 @@
// Copyright 2006 Nemanja Trifunovic
/*
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
#define UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
#include "utf8/checked.h"
#include "utf8/unchecked.h"
#endif // header guard

318
utf8/utf8/checked.h Normal file
View File

@ -0,0 +1,318 @@
// Copyright 2006 Nemanja Trifunovic
/*
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef UTF8_FOR_CPP_CHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
#define UTF8_FOR_CPP_CHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
#include "core.h"
#include <stdexcept>
namespace utf8
{
// Exceptions that may be thrown from the library functions.
class invalid_code_point : public std::exception {
uint32_t cp;
public:
invalid_code_point(uint32_t cp) : cp(cp) {}
virtual const char* what() const throw() { return "Invalid code point"; }
uint32_t code_point() const {return cp;}
};
class invalid_utf8 : public std::exception {
uint8_t u8;
public:
invalid_utf8 (uint8_t u) : u8(u) {}
virtual const char* what() const throw() { return "Invalid UTF-8"; }
uint8_t utf8_octet() const {return u8;}
};
class invalid_utf16 : public std::exception {
uint16_t u16;
public:
invalid_utf16 (uint16_t u) : u16(u) {}
virtual const char* what() const throw() { return "Invalid UTF-16"; }
uint16_t utf16_word() const {return u16;}
};
class not_enough_room : public std::exception {
public:
virtual const char* what() const throw() { return "Not enough space"; }
};
/// The library API - functions intended to be called by the users
template <typename octet_iterator, typename output_iterator>
output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out, uint32_t replacement)
{
while (start != end) {
octet_iterator sequence_start = start;
internal::utf_error err_code = internal::validate_next(start, end);
switch (err_code) {
case internal::OK :
for (octet_iterator it = sequence_start; it != start; ++it)
*out++ = *it;
break;
case internal::NOT_ENOUGH_ROOM:
throw not_enough_room();
case internal::INVALID_LEAD:
append (replacement, out);
++start;
break;
case internal::INCOMPLETE_SEQUENCE:
case internal::OVERLONG_SEQUENCE:
case internal::INVALID_CODE_POINT:
append (replacement, out);
++start;
// just one replacement mark for the sequence
while (internal::is_trail(*start) && start != end)
++start;
break;
}
}
return out;
}
template <typename octet_iterator, typename output_iterator>
inline output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out)
{
static const uint32_t replacement_marker = internal::mask16(0xfffd);
return replace_invalid(start, end, out, replacement_marker);
}
template <typename octet_iterator>
octet_iterator append(uint32_t cp, octet_iterator result)
{
if (!internal::is_code_point_valid(cp))
throw invalid_code_point(cp);
if (cp < 0x80) // one octet
*(result++) = static_cast<uint8_t>(cp);
else if (cp < 0x800) { // two octets
*(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
}
else if (cp < 0x10000) { // three octets
*(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
*(result++) = static_cast<uint8_t>((cp >> 6) & 0x3f | 0x80);
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
}
else if (cp <= internal::CODE_POINT_MAX) { // four octets
*(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
*(result++) = static_cast<uint8_t>((cp >> 12)& 0x3f | 0x80);
*(result++) = static_cast<uint8_t>((cp >> 6) & 0x3f | 0x80);
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
}
else
throw invalid_code_point(cp);
return result;
}
template <typename octet_iterator>
uint32_t next(octet_iterator& it, octet_iterator end)
{
uint32_t cp = 0;
internal::utf_error err_code = internal::validate_next(it, end, &cp);
switch (err_code) {
case internal::OK :
break;
case internal::NOT_ENOUGH_ROOM :
throw not_enough_room();
case internal::INVALID_LEAD :
case internal::INCOMPLETE_SEQUENCE :
case internal::OVERLONG_SEQUENCE :
throw invalid_utf8(*it);
case internal::INVALID_CODE_POINT :
throw invalid_code_point(cp);
}
return cp;
}
template <typename octet_iterator>
uint32_t peek_next(octet_iterator it, octet_iterator end)
{
return next(it, end);
}
template <typename octet_iterator>
uint32_t prior(octet_iterator& it, octet_iterator start)
{
octet_iterator end = it;
while (internal::is_trail(*(--it)))
if (it < start)
throw invalid_utf8(*it); // error - no lead byte in the sequence
octet_iterator temp = it;
return next(temp, end);
}
/// Deprecated in versions that include "prior"
template <typename octet_iterator>
uint32_t previous(octet_iterator& it, octet_iterator pass_start)
{
octet_iterator end = it;
while (internal::is_trail(*(--it)))
if (it == pass_start)
throw invalid_utf8(*it); // error - no lead byte in the sequence
octet_iterator temp = it;
return next(temp, end);
}
template <typename octet_iterator, typename distance_type>
void advance (octet_iterator& it, distance_type n, octet_iterator end)
{
for (distance_type i = 0; i < n; ++i)
next(it, end);
}
template <typename octet_iterator>
typename std::iterator_traits<octet_iterator>::difference_type
distance (octet_iterator first, octet_iterator last)
{
typename std::iterator_traits<octet_iterator>::difference_type dist;
for (dist = 0; first < last; ++dist)
next(first, last);
return dist;
}
template <typename u16bit_iterator, typename octet_iterator>
octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
{
while (start != end) {
uint32_t cp = internal::mask16(*start++);
// Take care of surrogate pairs first
if (internal::is_surrogate(cp)) {
if (start != end) {
uint32_t trail_surrogate = internal::mask16(*start++);
if (trail_surrogate >= internal::TRAIL_SURROGATE_MIN && trail_surrogate <= internal::TRAIL_SURROGATE_MAX)
cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
else
throw invalid_utf16(static_cast<uint16_t>(trail_surrogate));
}
else
throw invalid_utf16(static_cast<uint16_t>(*start));
}
result = append(cp, result);
}
return result;
}
template <typename u16bit_iterator, typename octet_iterator>
u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
{
while (start != end) {
uint32_t cp = next(start, end);
if (cp > 0xffff) { //make a surrogate pair
*result++ = static_cast<uint16_t>((cp >> 10) + internal::LEAD_OFFSET);
*result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN);
}
else
*result++ = static_cast<uint16_t>(cp);
}
return result;
}
template <typename octet_iterator, typename u32bit_iterator>
octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
{
while (start != end)
result = append(*(start++), result);
return result;
}
template <typename octet_iterator, typename u32bit_iterator>
u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
{
while (start < end)
(*result++) = next(start, end);
return result;
}
// The iterator class
template <typename octet_iterator>
class iterator : public std::iterator <std::bidirectional_iterator_tag, uint32_t> {
octet_iterator it;
octet_iterator range_start;
octet_iterator range_end;
public:
iterator () {};
explicit iterator (const octet_iterator& octet_it,
const octet_iterator& range_start,
const octet_iterator& range_end) :
it(octet_it), range_start(range_start), range_end(range_end)
{
if (it < range_start || it > range_end)
throw std::out_of_range("Invalid utf-8 iterator position");
}
// the default "big three" are OK
octet_iterator base () const { return it; }
uint32_t operator * () const
{
octet_iterator temp = it;
return next(temp, range_end);
}
bool operator == (const iterator& rhs) const
{
if (range_start != rhs.range_start || range_end != rhs.range_end)
throw std::logic_error("Comparing utf-8 iterators defined with different ranges");
return (it == rhs.it);
}
bool operator != (const iterator& rhs) const
{
return !(operator == (rhs));
}
iterator& operator ++ ()
{
next(it, range_end);
return *this;
}
iterator operator ++ (int)
{
iterator temp = *this;
next(it, range_end);
return temp;
}
iterator& operator -- ()
{
prior(it, range_start);
return *this;
}
iterator operator -- (int)
{
iterator temp = *this;
prior(it, range_start);
return temp;
}
}; // class iterator
} // namespace utf8
#endif //header guard

259
utf8/utf8/core.h Normal file
View File

@ -0,0 +1,259 @@
// Copyright 2006 Nemanja Trifunovic
/*
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef UTF8_FOR_CPP_CORE_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
#define UTF8_FOR_CPP_CORE_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
#include <iterator>
namespace utf8
{
// The typedefs for 8-bit, 16-bit and 32-bit unsigned integers
// You may need to change them to match your system.
// These typedefs have the same names as ones from cstdint, or boost/cstdint
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
// Helper code - not intended to be directly called by the library users. May be changed at any time
namespace internal
{
// Unicode constants
// Leading (high) surrogates: 0xd800 - 0xdbff
// Trailing (low) surrogates: 0xdc00 - 0xdfff
const uint16_t LEAD_SURROGATE_MIN = 0xd800u;
const uint16_t LEAD_SURROGATE_MAX = 0xdbffu;
const uint16_t TRAIL_SURROGATE_MIN = 0xdc00u;
const uint16_t TRAIL_SURROGATE_MAX = 0xdfffu;
const uint16_t LEAD_OFFSET = LEAD_SURROGATE_MIN - (0x10000 >> 10);
const uint32_t SURROGATE_OFFSET = 0x10000u - (LEAD_SURROGATE_MIN << 10) - TRAIL_SURROGATE_MIN;
// Maximum valid value for a Unicode code point
const uint32_t CODE_POINT_MAX = 0x0010ffffu;
template<typename octet_type>
inline uint8_t mask8(octet_type oc)
{
return static_cast<uint8_t>(0xff & oc);
}
template<typename u16_type>
inline uint16_t mask16(u16_type oc)
{
return static_cast<uint16_t>(0xffff & oc);
}
template<typename octet_type>
inline bool is_trail(octet_type oc)
{
return ((mask8(oc) >> 6) == 0x2);
}
template <typename u16>
inline bool is_surrogate(u16 cp)
{
return (cp >= LEAD_SURROGATE_MIN && cp <= TRAIL_SURROGATE_MAX);
}
template <typename u32>
inline bool is_code_point_valid(u32 cp)
{
return (cp <= CODE_POINT_MAX && !is_surrogate(cp) && cp != 0xfffe && cp != 0xffff);
}
template <typename octet_iterator>
inline typename std::iterator_traits<octet_iterator>::difference_type
sequence_length(octet_iterator lead_it)
{
uint8_t lead = mask8(*lead_it);
if (lead < 0x80)
return 1;
else if ((lead >> 5) == 0x6)
return 2;
else if ((lead >> 4) == 0xe)
return 3;
else if ((lead >> 3) == 0x1e)
return 4;
else
return 0;
}
enum utf_error {OK, NOT_ENOUGH_ROOM, INVALID_LEAD, INCOMPLETE_SEQUENCE, OVERLONG_SEQUENCE, INVALID_CODE_POINT};
template <typename octet_iterator>
utf_error validate_next(octet_iterator& it, octet_iterator end, uint32_t* code_point)
{
uint32_t cp = mask8(*it);
// Check the lead octet
typedef typename std::iterator_traits<octet_iterator>::difference_type octet_difference_type;
octet_difference_type length = sequence_length(it);
// "Shortcut" for ASCII characters
if (length == 1) {
if (end - it > 0) {
if (code_point)
*code_point = cp;
++it;
return OK;
}
else
return NOT_ENOUGH_ROOM;
}
// Do we have enough memory?
if (std::distance(it, end) < length)
return NOT_ENOUGH_ROOM;
// Check trail octets and calculate the code point
switch (length) {
case 0:
return INVALID_LEAD;
break;
case 2:
if (is_trail(*(++it))) {
cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
}
else {
--it;
return INCOMPLETE_SEQUENCE;
}
break;
case 3:
if (is_trail(*(++it))) {
cp = ((cp << 12) & 0xffff) + ((mask8(*it) << 6) & 0xfff);
if (is_trail(*(++it))) {
cp += (*it) & 0x3f;
}
else {
std::advance(it, -2);
return INCOMPLETE_SEQUENCE;
}
}
else {
--it;
return INCOMPLETE_SEQUENCE;
}
break;
case 4:
if (is_trail(*(++it))) {
cp = ((cp << 18) & 0x1fffff) + ((mask8(*it) << 12) & 0x3ffff);
if (is_trail(*(++it))) {
cp += (mask8(*it) << 6) & 0xfff;
if (is_trail(*(++it))) {
cp += (*it) & 0x3f;
}
else {
std::advance(it, -3);
return INCOMPLETE_SEQUENCE;
}
}
else {
std::advance(it, -2);
return INCOMPLETE_SEQUENCE;
}
}
else {
--it;
return INCOMPLETE_SEQUENCE;
}
break;
}
// Is the code point valid?
if (!is_code_point_valid(cp)) {
for (octet_difference_type i = 0; i < length - 1; ++i)
--it;
return INVALID_CODE_POINT;
}
if (code_point)
*code_point = cp;
if (cp < 0x80) {
if (length != 1) {
std::advance(it, (int)(-(length-1)));
return OVERLONG_SEQUENCE;
}
}
else if (cp < 0x800) {
if (length != 2) {
std::advance(it, (int)(-(length-1)));
return OVERLONG_SEQUENCE;
}
}
else if (cp < 0x10000) {
if (length != 3) {
std::advance(it, (int)(-(length-1)));
return OVERLONG_SEQUENCE;
}
}
++it;
return OK;
}
template <typename octet_iterator>
inline utf_error validate_next(octet_iterator& it, octet_iterator end) {
return validate_next(it, end, 0);
}
} // namespace internal
/// The library API - functions intended to be called by the users
// Byte order mark
const uint8_t bom[] = {0xef, 0xbb, 0xbf};
template <typename octet_iterator>
octet_iterator find_invalid(octet_iterator start, octet_iterator end)
{
octet_iterator result = start;
while (result != end) {
internal::utf_error err_code = internal::validate_next(result, end);
if (err_code != internal::OK)
return result;
}
return result;
}
template <typename octet_iterator>
inline bool is_valid(octet_iterator start, octet_iterator end)
{
return (find_invalid(start, end) == end);
}
template <typename octet_iterator>
inline bool is_bom (octet_iterator it)
{
return (
(internal::mask8(*it++)) == bom[0] &&
(internal::mask8(*it++)) == bom[1] &&
(internal::mask8(*it)) == bom[2]
);
}
} // namespace utf8
#endif // header guard

228
utf8/utf8/unchecked.h Normal file
View File

@ -0,0 +1,228 @@
// Copyright 2006 Nemanja Trifunovic
/*
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef UTF8_FOR_CPP_UNCHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
#define UTF8_FOR_CPP_UNCHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
#include "core.h"
namespace utf8
{
namespace unchecked
{
template <typename octet_iterator>
octet_iterator append(uint32_t cp, octet_iterator result)
{
if (cp < 0x80) // one octet
*(result++) = static_cast<uint8_t>(cp);
else if (cp < 0x800) { // two octets
*(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
}
else if (cp < 0x10000) { // three octets
*(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
*(result++) = static_cast<uint8_t>((cp >> 6) & 0x3f | 0x80);
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
}
else { // four octets
*(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
*(result++) = static_cast<uint8_t>((cp >> 12)& 0x3f | 0x80);
*(result++) = static_cast<uint8_t>((cp >> 6) & 0x3f | 0x80);
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
}
return result;
}
template <typename octet_iterator>
uint32_t next(octet_iterator& it)
{
uint32_t cp = internal::mask8(*it);
typename std::iterator_traits<octet_iterator>::difference_type length = utf8::internal::sequence_length(it);
switch (length) {
case 1:
break;
case 2:
it++;
cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
break;
case 3:
++it;
cp = ((cp << 12) & 0xffff) + ((internal::mask8(*it) << 6) & 0xfff);
++it;
cp += (*it) & 0x3f;
break;
case 4:
++it;
cp = ((cp << 18) & 0x1fffff) + ((internal::mask8(*it) << 12) & 0x3ffff);
++it;
cp += (internal::mask8(*it) << 6) & 0xfff;
++it;
cp += (*it) & 0x3f;
break;
}
++it;
return cp;
}
template <typename octet_iterator>
uint32_t peek_next(octet_iterator it)
{
return next(it);
}
template <typename octet_iterator>
uint32_t prior(octet_iterator& it)
{
while (internal::is_trail(*(--it))) ;
octet_iterator temp = it;
return next(temp);
}
// Deprecated in versions that include prior, but only for the sake of consistency (see utf8::previous)
template <typename octet_iterator>
inline uint32_t previous(octet_iterator& it)
{
return prior(it);
}
template <typename octet_iterator, typename distance_type>
void advance (octet_iterator& it, distance_type n)
{
for (distance_type i = 0; i < n; ++i)
next(it);
}
template <typename octet_iterator>
typename std::iterator_traits<octet_iterator>::difference_type
distance (octet_iterator first, octet_iterator last)
{
typename std::iterator_traits<octet_iterator>::difference_type dist;
for (dist = 0; first < last; ++dist)
next(first);
return dist;
}
template <typename u16bit_iterator, typename octet_iterator>
octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
{
while (start != end) {
uint32_t cp = internal::mask16(*start++);
// Take care of surrogate pairs first
if (internal::is_surrogate(cp)) {
uint32_t trail_surrogate = internal::mask16(*start++);
cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
}
result = append(cp, result);
}
return result;
}
template <typename u16bit_iterator, typename octet_iterator>
u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
{
while (start != end) {
uint32_t cp = next(start);
if (cp > 0xffff) { //make a surrogate pair
*result++ = static_cast<uint16_t>((cp >> 10) + internal::LEAD_OFFSET);
*result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN);
}
else
*result++ = static_cast<uint16_t>(cp);
}
return result;
}
template <typename octet_iterator, typename u32bit_iterator>
octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
{
while (start != end)
result = append(*(start++), result);
return result;
}
template <typename octet_iterator, typename u32bit_iterator>
u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
{
while (start < end)
(*result++) = next(start);
return result;
}
// The iterator class
template <typename octet_iterator>
class iterator : public std::iterator <std::bidirectional_iterator_tag, uint32_t> {
octet_iterator it;
public:
iterator () {};
explicit iterator (const octet_iterator& octet_it): it(octet_it) {}
// the default "big three" are OK
octet_iterator base () const { return it; }
uint32_t operator * () const
{
octet_iterator temp = it;
return next(temp);
}
bool operator == (const iterator& rhs) const
{
return (it == rhs.it);
}
bool operator != (const iterator& rhs) const
{
return !(operator == (rhs));
}
iterator& operator ++ ()
{
std::advance(it, internal::sequence_length(it));
return *this;
}
iterator operator ++ (int)
{
iterator temp = *this;
std::advance(it, internal::sequence_length(it));
return temp;
}
iterator& operator -- ()
{
prior(it);
return *this;
}
iterator operator -- (int)
{
iterator temp = *this;
prior(it);
return temp;
}
}; // class iterator
} // namespace utf8::unchecked
} // namespace utf8
#endif // header guard

1
version.txt Normal file
View File

@ -0,0 +1 @@
16