Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add SyncClient draft to git

  • Loading branch information...
commit 8f32f23016adf3de1ab40fae3ac015deb31b8dd0 1 parent e8eca4b
genywind genywind authored
5 .gitignore
View
@@ -106,6 +106,10 @@ platform/android/**/default.properties
Manifest.txt
spec/framework_spec/faillog.txt
+spec/framework_spec/preverified/*
+spec/phone_spec/preverified/*
+spec/phone_spec/RhoBundle/*
+spec/phone_spec/last_bbver
platform/shared/curl/lib/rhoconf.h
.idea
@@ -116,3 +120,4 @@ platform/bb/Hsqldb/Hsqldb.jar
platform/bb/RhoBundle/RhoBundle.jar
platform/bb/RubyVM/RubyVM.jar
platform/bb/rhodes/rhodes.jar
+
223 platform/shared/SyncClient/SyncClient.cpp
View
@@ -0,0 +1,223 @@
+#include "SyncClient.h"
+
+#include "stdafx.h"
+
+#include "common/RhodesAppBase.h"
+#include "sync/SyncThread.h"
+#include "common/RhoFile.h"
+#include "common/Tokenizer.h"
+#include "common/RhoConf.h"
+#include "common/RhoError.h"
+
+using namespace rho;
+using namespace rho::common;
+String getSyncTypeName( RHOM_SYNC_TYPE sync_type );
+void parseSyncNotify(const char* msg, RHO_SYNC_NOTIFY* pNotify);
+
+extern "C"
+{
+
+void rho_syncclient_initmodel(RHOM_MODEL* model)
+{
+ memset( model, 0, sizeof(RHOM_MODEL) );
+ model->type = RMT_PROPERTY_BAG;
+ model->sync_type = RST_NONE;
+ model->sync_priority = 1000;
+ model->partition = "user";
+}
+
+void rho_syncclient_free_syncnotify(RHO_SYNC_NOTIFY* pNotify)
+{
+ if (!pNotify)
+ return;
+
+ if ( pNotify->source_name != null )
+ free(pNotify->source_name);
+
+ if ( pNotify->status != null )
+ free(pNotify->status);
+
+ if ( pNotify->error_message != null )
+ free(pNotify->error_message);
+
+ if ( pNotify->callback_params != null )
+ free(pNotify->callback_params);
+
+ memset( pNotify, 0, sizeof(RHO_SYNC_NOTIFY) );
+}
+
+void rho_syncclient_processmodels(RHOM_MODEL* pModels, int nModels)
+{
+ db::CDBAdapter& oUserDB = db::CDBAdapter::getUserDB();
+ int nStartModelID = 1;
+ {
+ DBResult( res, oUserDB.executeSQL("SELECT MAX(source_id) AS maxid FROM sources"));
+ if ( !res.isEnd() )
+ nStartModelID = res.getIntByIdx(0)+2;
+ }
+
+ for ( int i = 0; i < nModels; i++ )
+ {
+ RHOM_MODEL& model = pModels[i];
+ DBResult( res, oUserDB.executeSQL("SELECT sync_priority,source_id,partition, sync_type, schema_version, associations, blob_attribs FROM sources WHERE name=?",
+ model.name) );
+
+ if ( !res.isEnd() )
+ {
+ oUserDB.executeSQL("UPDATE sources SET sync_priority=?, sync_type=?, partition=?, schema_version=?, associations=?, blob_attribs=?",
+ model.sync_priority, getSyncTypeName(model.sync_type), model.partition, "", "", "" );
+
+ }else //new model
+ {
+ oUserDB.executeSQL("INSERT INTO sources (source_id,name,sync_priority, sync_type, partition, schema_version, associations, blob_attribs) values (?,?,?,?,?,?,?,?) ",
+ nStartModelID, model.name, model.sync_priority, getSyncTypeName(model.sync_type), model.partition, "", "", "" );
+
+ nStartModelID++;
+ }
+ }
+}
+
+void rho_syncclient_init(RHOM_MODEL* pModels, int nModels)
+{
+ rho_logconf_Init(rho_native_rhopath());
+ CRhodesAppBase::Create( rho_native_rhopath() );
+
+ String strDbPath = rho_native_rhopath();
+
+ //create db and db-files folder
+ CRhoFile::createFolder( (strDbPath + "db/db-files").c_str());
+
+ for( int i = 0; i < nModels; i++ )
+ {
+ RHOM_MODEL& model = pModels[i];
+
+ String strDbPartition = strDbPath + "db/syncdb";
+ strDbPartition += model.partition;
+ strDbPartition += ".sqlite";
+
+ void* pDB = 0;
+ rho_db_open( strDbPartition.c_str(), model.partition, &pDB);
+ }
+
+ //process models
+ rho_syncclient_processmodels(pModels, nModels);
+
+ rho_db_init_attr_manager();
+
+ LOG(INFO) + "Starting sync engine...";
+ sync::CSyncThread::Create(common::rho_impl_createClassFactory());
+
+}
+
+void rho_syncclient_database_full_reset_and_logout()
+{
+ rho_sync_logout();
+
+ db::CDBAdapter& oUserDB = db::CDBAdapter::getUserDB();
+ oUserDB.executeSQL("UPDATE client_info SET reset=1");
+
+ if ( rho_conf_is_property_exists("bulksync_state") )
+ rho_conf_setInt("bulksync_state", 0 );
+
+ oUserDB.executeSQL("UPDATE sources SET token=0");
+
+ Vector<String> arExclude;
+ arExclude.addElement("sources");
+ arExclude.addElement("client_info");
+ db::CDBAdapter::destroy_tables_allpartitions(Vector<String>(), arExclude);
+
+ //TODO: scema_sources
+ //hash_migrate = {}
+ //::Rho::RHO.init_schema_sources(hash_migrate)
+}
+
+void rho_syncclient_destroy()
+{
+ sync::CSyncThread::Destroy();
+}
+
+void rho_syncclient_parsenotify(const char* msg, RHO_SYNC_NOTIFY* pNotify)
+{
+ CTokenizer oTokenizer( msg, "&" );
+ int nLastPos = 0;
+ while (oTokenizer.hasMoreTokens())
+ {
+ nLastPos = oTokenizer.getCurPos();
+
+ String tok = oTokenizer.nextToken();
+ if (tok.length() == 0)
+ continue;
+
+ CTokenizer oValueTok( tok, "=" );
+ String name = oValueTok.nextToken();
+ String value = oValueTok.nextToken();
+
+ if ( name.compare("total_count") == 0)
+ convertFromStringA( value.c_str(), pNotify->total_count );
+ else if ( name.compare("processed_count") == 0)
+ convertFromStringA( value.c_str(), pNotify->processed_count );
+ else if ( name.compare("cumulative_count") == 0)
+ convertFromStringA( value.c_str(), pNotify->cumulative_count );
+ else if ( name.compare("source_id") == 0)
+ convertFromStringA( value.c_str(), pNotify->source_id );
+ else if ( name.compare("error_code") == 0)
+ convertFromStringA( value.c_str(), pNotify->error_code );
+ else if ( name.compare("source_name") == 0)
+ pNotify->source_name = strdup(value.c_str());
+ else if ( name.compare("status") == 0)
+ pNotify->status = strdup(value.c_str());
+ else if ( name.compare("error_message") == 0)
+ pNotify->error_message = strdup(value.c_str());
+ else if ( name.compare("rho_callback") != 0)
+ break;
+
+ nLastPos = oTokenizer.getCurPos();
+ }
+
+ if ( nLastPos < (int)strlen(msg) )
+ pNotify->callback_params = strdup(msg+nLastPos);
+}
+
+}
+
+String getSyncTypeName( RHOM_SYNC_TYPE sync_type )
+{
+ switch( sync_type)
+ {
+ case RST_INCREMENTAL:
+ return "incremental";
+ case RST_BULK_ONLY:
+ return "bulk_only";
+ }
+
+ return "none";
+}
+
+extern "C"
+{
+extern "C" void alert_show_popup(const char* message)
+{
+
+}
+
+void rho_ruby_loadserversources(const char* szData)
+{
+ //TODO: loadserversources : see rho.rb
+}
+
+const char* rho_ruby_getMessageText(const char* szName)
+{
+ return szName;
+}
+
+const char* rho_ruby_getErrorText(int nError)
+{
+ return "";
+}
+
+char* RhoRuby_getRhoDBVersion()
+{
+ return "1.0";
+}
+
+}
45 platform/shared/SyncClient/SyncClient.h
View
@@ -0,0 +1,45 @@
+#pragma once
+
+typedef enum _RHOM_MODEL_TYPE { RMT_PROPERTY_BAG=1, RMT_PROPERTY_FIXEDSCHEMA=2 } RHOM_MODEL_TYPE;
+typedef enum _RHOM_SYNC_TYPE { RST_NONE = 0, RST_INCREMENTAL=1, RST_BULK_ONLY=2 } RHOM_SYNC_TYPE;
+typedef struct _RHOM_MODEL
+{
+ const char* name;
+ RHOM_MODEL_TYPE type;
+
+ RHOM_SYNC_TYPE sync_type;
+ int sync_priority;
+
+ const char* partition;
+ //TODO: scema model parameters
+
+}RHOM_MODEL;
+
+typedef struct _RHO_SYNC_NOTIFY
+{
+ int total_count;
+ int processed_count;
+ int cumulative_count;
+ int source_id;
+ char* source_name;
+ char* status;
+ int error_code;
+ char* error_message;
+ char* callback_params;
+}RHO_SYNC_NOTIFY;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif //__cplusplus
+
+void rho_syncclient_initmodel(RHOM_MODEL* model);
+void rho_syncclient_init(RHOM_MODEL* pModels, int nModels);
+void rho_syncclient_destroy();
+void rho_syncclient_database_full_reset_and_logout();
+void rho_syncclient_parsenotify(const char* msg, RHO_SYNC_NOTIFY* pNotify);
+void rho_syncclient_free_syncnotify(RHO_SYNC_NOTIFY* pNotify);
+
+#ifdef __cplusplus
+};
+#endif //__cplusplus
65 platform/win32/SyncClient/SyncClient.sln
View
@@ -0,0 +1,65 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SyncClient", "SyncClient.vcproj", "{F6AB17D4-B0D0-4F10-9D15-87AE05590133}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SyncClientTest", "SyncClientTest\SyncClientTest.vcproj", "{0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}"
+ ProjectSection(ProjectDependencies) = postProject
+ {F6AB17D4-B0D0-4F10-9D15-87AE05590133} = {F6AB17D4-B0D0-4F10-9D15-87AE05590133}
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Pocket PC 2003 (ARMV4) = Debug|Pocket PC 2003 (ARMV4)
+ Debug|Smartphone 2003 (ARMV4) = Debug|Smartphone 2003 (ARMV4)
+ Debug|Win32 = Debug|Win32
+ Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
+ Debug|Windows Mobile 5.0 Smartphone SDK (ARMV4I) = Debug|Windows Mobile 5.0 Smartphone SDK (ARMV4I)
+ Debug|Windows Mobile 6 Professional SDK (ARMV4I) = Debug|Windows Mobile 6 Professional SDK (ARMV4I)
+ Debug|Windows Mobile 6 Standard SDK (ARMV4I) = Debug|Windows Mobile 6 Standard SDK (ARMV4I)
+ Release|Pocket PC 2003 (ARMV4) = Release|Pocket PC 2003 (ARMV4)
+ Release|Smartphone 2003 (ARMV4) = Release|Smartphone 2003 (ARMV4)
+ Release|Win32 = Release|Win32
+ Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
+ Release|Windows Mobile 5.0 Smartphone SDK (ARMV4I) = Release|Windows Mobile 5.0 Smartphone SDK (ARMV4I)
+ Release|Windows Mobile 6 Professional SDK (ARMV4I) = Release|Windows Mobile 6 Professional SDK (ARMV4I)
+ Release|Windows Mobile 6 Standard SDK (ARMV4I) = Release|Windows Mobile 6 Standard SDK (ARMV4I)
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {F6AB17D4-B0D0-4F10-9D15-87AE05590133}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Win32
+ {F6AB17D4-B0D0-4F10-9D15-87AE05590133}.Debug|Smartphone 2003 (ARMV4).ActiveCfg = Debug|Win32
+ {F6AB17D4-B0D0-4F10-9D15-87AE05590133}.Debug|Win32.ActiveCfg = Debug|Win32
+ {F6AB17D4-B0D0-4F10-9D15-87AE05590133}.Debug|Win32.Build.0 = Debug|Win32
+ {F6AB17D4-B0D0-4F10-9D15-87AE05590133}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32
+ {F6AB17D4-B0D0-4F10-9D15-87AE05590133}.Debug|Windows Mobile 5.0 Smartphone SDK (ARMV4I).ActiveCfg = Debug|Win32
+ {F6AB17D4-B0D0-4F10-9D15-87AE05590133}.Debug|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Debug|Win32
+ {F6AB17D4-B0D0-4F10-9D15-87AE05590133}.Debug|Windows Mobile 6 Standard SDK (ARMV4I).ActiveCfg = Debug|Win32
+ {F6AB17D4-B0D0-4F10-9D15-87AE05590133}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Win32
+ {F6AB17D4-B0D0-4F10-9D15-87AE05590133}.Release|Smartphone 2003 (ARMV4).ActiveCfg = Release|Win32
+ {F6AB17D4-B0D0-4F10-9D15-87AE05590133}.Release|Win32.ActiveCfg = Release|Win32
+ {F6AB17D4-B0D0-4F10-9D15-87AE05590133}.Release|Win32.Build.0 = Release|Win32
+ {F6AB17D4-B0D0-4F10-9D15-87AE05590133}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32
+ {F6AB17D4-B0D0-4F10-9D15-87AE05590133}.Release|Windows Mobile 5.0 Smartphone SDK (ARMV4I).ActiveCfg = Release|Win32
+ {F6AB17D4-B0D0-4F10-9D15-87AE05590133}.Release|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Release|Win32
+ {F6AB17D4-B0D0-4F10-9D15-87AE05590133}.Release|Windows Mobile 6 Standard SDK (ARMV4I).ActiveCfg = Release|Win32
+ {0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Win32
+ {0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}.Debug|Smartphone 2003 (ARMV4).ActiveCfg = Debug|Win32
+ {0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}.Debug|Win32.ActiveCfg = Debug|Win32
+ {0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}.Debug|Win32.Build.0 = Debug|Win32
+ {0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32
+ {0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}.Debug|Windows Mobile 5.0 Smartphone SDK (ARMV4I).ActiveCfg = Debug|Win32
+ {0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}.Debug|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Debug|Win32
+ {0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}.Debug|Windows Mobile 6 Standard SDK (ARMV4I).ActiveCfg = Debug|Win32
+ {0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Win32
+ {0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}.Release|Smartphone 2003 (ARMV4).ActiveCfg = Release|Win32
+ {0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}.Release|Win32.ActiveCfg = Release|Win32
+ {0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}.Release|Win32.Build.0 = Release|Win32
+ {0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32
+ {0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}.Release|Windows Mobile 5.0 Smartphone SDK (ARMV4I).ActiveCfg = Release|Win32
+ {0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}.Release|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Release|Win32
+ {0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}.Release|Windows Mobile 6 Standard SDK (ARMV4I).ActiveCfg = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
576 platform/win32/SyncClient/SyncClient.vcproj
View
@@ -0,0 +1,576 @@
+<?xml version="1.0" encoding="windows-1251"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="SyncClient"
+ ProjectGUID="{F6AB17D4-B0D0-4F10-9D15-87AE05590133}"
+ RootNamespace="SyncClient"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="..\bin\$(PlatformName)\$(ProjectName)\$(ConfigurationName)"
+ IntermediateDirectory="..\bin\$(PlatformName)\$(ProjectName)\$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=".;../../shared"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;RHO_NO_RUBY"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../shared"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="rho"
+ >
+ <File
+ RelativePath="..\..\shared\common\RhodesAppBase.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\RhodesAppBase.h"
+ >
+ </File>
+ <Filter
+ Name="common"
+ >
+ <File
+ RelativePath="..\..\shared\common\AutoPointer.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\InputStream.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\IRhoClassFactory.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\IRhoThreadImpl.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\RhoConf.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\RhoConf.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\RhoDefs.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\RhoFatalError.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\RhoFile.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\RhoFile.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\RhoFilePath.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\RhoMutexLock.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\RhoPort.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\RhoStd.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\RhoSystem.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\RhoThread.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\RhoThread.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\RhoTime.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\stat.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\StringConverter.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\ThreadQueue.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\ThreadQueue.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\Tokenizer.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\common\Tokenizer.h"
+ >
+ </File>
+ <Filter
+ Name="win"
+ >
+ <File
+ RelativePath="..\..\wm\rhodes\rho\common\RhoClassFactory.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\wm\rhodes\rho\common\RhoClassFactory.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\wm\rhodes\rho\common\RhoThreadImpl.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\wm\rhodes\rho\common\RhoThreadImpl.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="net"
+ >
+ <File
+ RelativePath="..\..\shared\net\INetRequest.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\net\URI.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\net\URI.h"
+ >
+ </File>
+ <Filter
+ Name="win"
+ >
+ <File
+ RelativePath="..\..\wm\rhodes\rho\net\NetRequest.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\wm\rhodes\rho\net\netrequest.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\wm\rhodes\rho\net\NetRequestImpl.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\wm\rhodes\rho\net\NetRequestImpl.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="logging"
+ >
+ <File
+ RelativePath="..\..\shared\logging\RhoATLTrace.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\logging\RhoLog.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\logging\RhoLog.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\logging\RhoLogCat.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\logging\RhoLogConf.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\logging\RhoLogConf.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\logging\RhoLogSink.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\logging\RhoLogSink.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\logging\RhoPlainLog.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="db"
+ >
+ <File
+ RelativePath="..\..\shared\db\DBAdapter.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\db\DBAdapter.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\db\DBAttrManager.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\db\DBAttrManager.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\db\DBResult.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\db\DBResult.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="json"
+ >
+ <File
+ RelativePath="..\..\shared\json\arraylist.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\arraylist.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\bits.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\config.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\debug.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\debug.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\json.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\json_object.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\json_object.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\json_object_private.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\json_tokener.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\json_tokener.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\json_util.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\json_util.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\JSONIterator.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\JSONIterator.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\linkhash.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\linkhash.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\printbuf.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\json\printbuf.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="sync"
+ >
+ <File
+ RelativePath="..\..\shared\sync\ClientRegister.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\sync\ClientRegister.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\sync\ISyncProtocol.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\sync\SyncEngine.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\sync\SyncEngine.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\sync\SyncNotify.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\sync\SyncNotify.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\sync\SyncProtocol_3.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\sync\SyncSource.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\sync\SyncSource.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\sync\SyncThread.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\sync\SyncThread.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="unzip"
+ >
+ <File
+ RelativePath="..\..\shared\unzip\unzip.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\unzip\unzip.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="rubyext"
+ >
+ <File
+ RelativePath="..\..\shared\rubyext\RhoRuby.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\rubyext\RhoRuby.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="SyncClient"
+ >
+ <File
+ RelativePath="..\..\shared\SyncClient\SyncClient.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\shared\SyncClient\SyncClient.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ <File
+ RelativePath="..\..\shared\sqlite\sqlite3.c"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
108 platform/win32/SyncClient/SyncClientTest/SyncClientTest.cpp
View
@@ -0,0 +1,108 @@
+#include "stdafx.h"
+
+#include "SyncClient/SyncClient.h"
+#include "sync/SyncThread.h"
+#include "common/RhoConf.h"
+#include "common/RhoError.h"
+
+#include "gtest/gtest.h"
+#include "test/test_helper.h"
+
+using namespace rho;
+using namespace rho::common;
+
+int _tmain(int argc, _TCHAR* argv[])
+{
+ RHOM_MODEL models[2] = {0};
+ rho_syncclient_initmodel(&models[0]);
+ models[0].name = "Customer";
+ models[0].sync_type = RST_INCREMENTAL;
+
+ rho_syncclient_initmodel(&models[1]);
+ models[1].name = "Product";
+ models[1].sync_type = RST_INCREMENTAL;
+
+ rho_syncclient_init(models, 2);
+
+ rho_sync_set_threaded_mode(0);
+
+//run tests
+ testing::InitGoogleTest(&argc, argv);
+ RUN_ALL_TESTS();
+//
+
+ rho_syncclient_destroy();
+
+ return 0;
+}
+
+TEST(SyncClient, ResetAndLogout)
+{
+ rho_sync_set_syncserver("http://rhodes-store-server.heroku.com/application");
+
+ rho_syncclient_database_full_reset_and_logout();
+
+ EXPECT_EQ(rho_sync_logged_in(), 0);
+}
+
+TEST(SyncClient, UpdateSyncServer)
+{
+ char* saveSrv = rho_conf_getString("syncserver");
+ rho_sync_set_syncserver("http://example.com/sources/");
+ char* newSrv = rho_conf_getString("syncserver");
+ EXPECT_EQ(String(newSrv), "http://example.com/sources/");
+ rho_conf_freeString(newSrv);
+
+ rho_sync_set_syncserver(saveSrv);
+ newSrv = rho_conf_getString("syncserver");
+ EXPECT_EQ(String(newSrv), saveSrv);
+ rho_conf_freeString(saveSrv);
+}
+
+TEST(SyncClient, shouldNotSyncWithoutLogin)
+{
+ EXPECT_EQ(rho_sync_logged_in(), 0);
+
+ char* szRes = (char*)rho_sync_doSyncSourceByName("Product");
+ RHO_SYNC_NOTIFY oNotify = {0};
+ rho_syncclient_parsenotify(szRes, &oNotify);
+
+ EXPECT_EQ(String(oNotify.status), "error");
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_CLIENTISNOTLOGGEDIN);
+
+ rho_syncclient_free_syncnotify(&oNotify);
+ rho_sync_free_string(szRes);
+}
+
+TEST(SyncClient, shouldLogin)
+{
+ EXPECT_EQ(rho_sync_logged_in(), 0);
+
+ char* szRes = (char*)rho_sync_login("lars", "larspass", "");
+ RHO_SYNC_NOTIFY oNotify = {0};
+ rho_syncclient_parsenotify(szRes, &oNotify);
+
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_NONE);
+ EXPECT_EQ(rho_sync_logged_in(), 1);
+
+ rho_syncclient_free_syncnotify(&oNotify);
+ rho_sync_free_string(szRes);
+
+}
+
+TEST(SyncClient, shouldSyncProduct)
+{
+ EXPECT_EQ(rho_sync_logged_in(), 1);
+
+ char* szRes = (char*)rho_sync_doSyncSourceByName("Product");
+ RHO_SYNC_NOTIFY oNotify = {0};
+ rho_syncclient_parsenotify(szRes, &oNotify);
+
+ EXPECT_EQ(String(oNotify.status), "ok");
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_NONE);
+
+ rho_syncclient_free_syncnotify(&oNotify);
+ rho_sync_free_string(szRes);
+
+}
+
221 platform/win32/SyncClient/SyncClientTest/SyncClientTest.vcproj
View
@@ -0,0 +1,221 @@
+<?xml version="1.0" encoding="windows-1251"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="SyncClientTest"
+ ProjectGUID="{0D5EBF57-73AF-443F-B8A0-D2149AB4C5C0}"
+ RootNamespace="SyncClientTest"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="..\..\bin\$(PlatformName)\$(ProjectName)\$(ConfigurationName)"
+ IntermediateDirectory="..\..\bin\$(PlatformName)\$(ProjectName)\$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../shared;../../../shared/test/gtest/include;../../../shared/test/gtest"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="wininet.lib ws2_32.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="test"
+ >
+ <File
+ RelativePath="..\..\..\shared\test\test_helper.cpp"
+ >
+ </File>
+ <Filter
+ Name="gtest"
+ >
+ <File
+ RelativePath="..\..\..\shared\test\gtest\src\gtest-death-test.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\shared\test\gtest\src\gtest-filepath.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\shared\test\gtest\src\gtest-internal-inl.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\shared\test\gtest\src\gtest-port.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\shared\test\gtest\src\gtest-test-part.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\shared\test\gtest\src\gtest-typed-test.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\shared\test\gtest\src\gtest.cc"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ <File
+ RelativePath=".\SyncClientTest.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
22 platform/win32/SyncClient/SyncClientTest/stdafx.h
View
@@ -0,0 +1,22 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
+#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#define _CRT_SECURE_NO_WARNINGS 1
+#define _CRT_NONSTDC_NO_WARNINGS 1
+#define _CRT_NON_CONFORMING_SWPRINTFS 1
+
+//#include <stdio.h>
+//#include <tchar.h>
+
+#include <atlbase.h>
+#include <atlstr.h>
+
+// TODO: reference additional headers your program requires here
22 platform/win32/SyncClient/stdafx.h
View
@@ -0,0 +1,22 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
+#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#define _CRT_SECURE_NO_WARNINGS 1
+#define _CRT_NONSTDC_NO_WARNINGS 1
+#define _CRT_NON_CONFORMING_SWPRINTFS 1
+
+//#include <stdio.h>
+//#include <tchar.h>
+
+#include <atlbase.h>
+#include <atlstr.h>
+
+// TODO: reference additional headers your program requires here
Please sign in to comment.
Something went wrong with that request. Please try again.