#include "SrcUpdater.h" #define LLOG(x) //RLOG(x) #define LDUMP(x) //RDUMP(x) //#define IMAGECLASS IdeImg //#define IMAGEFILE //#include void LoadUpdaterCfg(){ String cfg=ConfigFile("updates.xml"); if(FileExists(cfg)){ LoadFromXMLFile(UpdaterCfg(),cfg); }else{ UpdaterCfg().method=0; UpdaterCfg().sync=0; UpdaterCfg().period=0; UpdaterCfg().last=Null; UpdaterCfg().ignored=0; UpdaterCfg().localsrc=GetHomeDirFile("upp"); UpdaterCfg().svnserver="http://upp-mirror.googlecode.com/svn/trunk/"; UpdaterCfg().svnuser=""; UpdaterCfg().svnpass=""; } UpdaterCfg().globalsrc=FindGlobalSrc(); UpdaterCfg().available=false; } String GetSrcVersion(const char* dir,String& error){ String fn=AppendFileName(dir,"uppsrc/ide/version.h"); String ver=LoadFile(fn); if(ver.IsVoid()){ error="Can't read file "+fn; }else{ ver=ver.Mid(ver.Find("IDE_VERSION")+12); ver=ver.Mid(ver.Find('"')+1); ver=ver.Left(ver.Find('"')); } LLOG("GetSrcVersion("<UpdaterCfg().ignored) CheckLocalSvn(); } void SourceUpdater::DoUpdate(){ Close();Hide(); LLOG("DoUpdate"); switch(UpdaterCfg().method){ case 0: { //copy in /home LocalSync ls; if(ls.Execute()==IDOK){ ls.Perform(); //DeleteFile(ConfigFile("md5sums")); FileCopy(AppendFileName(UpdaterCfg().globalsrc,"uppsrc/ide/version.h"),AppendFileName(UpdaterCfg().localsrc,"uppsrc/ide/version.h")); } break; } case 2: { //svn repository SaveFile(AppendFileName(UpdaterCfg().localsrc,"uppsrc/ide/version.h"),"#define IDE_VERSION \"\"\n"); SvnSync ss; ss.Dir(UpdaterCfg().localsrc,UpdaterCfg().svnreadonly); if(UpdaterCfg().sync==1){ ss.FixRevision(UpdaterCfg().localsrc,ScanInt(global)); } ss.DoSync(); SaveFile(AppendFileName(UpdaterCfg().localsrc,"uppsrc/ide/version.h"),"#define IDE_VERSION \""+global+"\"\n"); break; } default: return; } UpdaterCfg().available=(ScanInt(global)>ScanInt(GetSrcVersion(UpdaterCfg().localsrc,error))); } void SourceUpdater::Ignore(){ UpdaterCfg().ignored=ScanInt(global); UpdaterCfg().available=false; Close(); }