UpdateExport.cpp
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:4k
源码类别:

模拟服务器

开发平台:

C/C++

  1. //////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  FileName    :   UpdateExport.cpp
  4. //  Version     :   1.0
  5. //  Creater     :   Cheng bitao
  6. //  Date        :   2002-11-28 17:24:46
  7. //  Comment     :   
  8. //
  9. //////////////////////////////////////////////////////////////////////////////////////
  10. #include "Stdafx.h"
  11. #include "UpdateExport.h"
  12. #include "UpdateDLL.h"
  13. #include "UpdateData.h"
  14. #include "UpdatePublic.h"
  15. extern CUpdateDLLApp g_theApp;
  16. int __stdcall Update_Init(KUPDATE_SETTING UpdateSetting)
  17. {
  18.     return g_theApp.Init(UpdateSetting);
  19. }
  20. int __stdcall Update_UnInit()
  21. {
  22.     return g_theApp.UnInit();
  23. }
  24. extern KUPDATE_DATA g_UpdateData;
  25. int __stdcall Update_Start()
  26. {
  27. //MessageBox(NULL,"旧的UPDATEDLL.DLL","",0);
  28.     int nRetCode = 0;
  29. CString sLog;
  30. sLog = g_UpdateData.szHostURL;
  31. g_UpdateData.SaveLog.WriteLogString(sLog, true);
  32.     if (g_theApp.m_pfnCallBackProc)
  33.     {
  34.         if (g_theApp.m_pfnCallBackProc(defUPDATE_STATUS_VERIFING, 0))
  35. {
  36. nRetCode = defUPDATE_RESULT_CANCEL;
  37. goto Exit0;
  38. }
  39.     }
  40. TRACE0("UserVerifyn");
  41.     nRetCode = g_theApp.UserVerify();
  42. TRACE0("UserVerify Endn");
  43.     if (nRetCode != defUPDATE_RESULT_USER_VERIFY_SUCCESS)
  44.         return nRetCode;
  45.     if (g_theApp.m_pfnCallBackProc)
  46.     {
  47.         g_theApp.m_pfnCallBackProc(defUPDATE_STATUS_VERIFING, 100);
  48.     }
  49.     if (g_theApp.m_pfnCallBackProc)
  50.     {
  51.         if (g_theApp.m_pfnCallBackProc(defUPDATE_STATUS_PROCESSING_INDEX, 0))
  52. {
  53. nRetCode = defUPDATE_RESULT_CANCEL;
  54. goto Exit0;
  55. }
  56.     }
  57. TRACE0("CheckNeedUpdaten");
  58.     nRetCode = g_theApp.CheckNeedUpdate();
  59. TRACE0("CheckNeedUpdate Endn");
  60.     if (nRetCode != defUPDATE_RESULT_PROCESS_INDEX_SUCCESS)
  61.     {
  62. if (nRetCode == defUPDATE_RESULT_NOT_UPDATE_FILE)
  63. {
  64. sLog = "Not Update File OK!";
  65. g_UpdateData.SaveLog.WriteLogString(sLog, true);
  66. return nRetCode;
  67. }
  68. if(nRetCode == 1)
  69. {
  70. // if (g_theApp.m_pfnCallBackProc)
  71. {
  72. // g_theApp.m_pfnCallBackProc(defUPDATE_RESULT_UPDATE_SUCCESS, 0);
  73. return defUPDATE_RESULT_UPDATE_SUCCESS;
  74.     }
  75. }
  76. if( nRetCode == defVersionNotenough)
  77. {
  78. if (g_theApp.m_pfnCallBackProc)
  79. {
  80. g_theApp.m_pfnCallBackProc(defUPDATE_RESULT_VERSION_NOT_ENOUGH, (long)&g_ProcessIndex.url[0]);
  81.     }
  82. return nRetCode;
  83. }
  84. if( nRetCode == defVersionMore)
  85. {
  86. if (g_theApp.m_pfnCallBackProc)
  87. {
  88. g_theApp.m_pfnCallBackProc(defUPDATE_RESULT_VERSION_MORE, 0);
  89.     }
  90. return nRetCode;
  91. }
  92. sLog = "Process Index.dat Failed!";
  93. g_UpdateData.SaveLog.WriteLogString(sLog, true);
  94. if (g_theApp.m_pfnCallBackProc)
  95. {
  96. g_theApp.m_pfnCallBackProc(defUPDATE_STATUS_PROCESSING_INDEX, 0);
  97. }
  98. return nRetCode;
  99. }
  100. sLog = "Process Index.dat OK!";
  101. g_UpdateData.SaveLog.WriteLogString(sLog, true);
  102. if (g_theApp.m_pfnCallBackProc)
  103.     {
  104.         g_theApp.m_pfnCallBackProc(defUPDATE_STATUS_PROCESSING_INDEX, 100);
  105.     }
  106. if (g_theApp.m_pfnCallBackProc)
  107.     {
  108.         if (g_theApp.m_pfnCallBackProc(defUPDATE_STATUS_DOWNLOADING, 0))
  109. {
  110. nRetCode = defUPDATE_RESULT_CANCEL;
  111. goto Exit0;
  112. }
  113.     }
  114. TRACE0("Downloadn");
  115.     nRetCode = g_theApp.Download();
  116. TRACE0("Download Endn");
  117.     if (nRetCode != defUPDATE_RESULT_DOWNLOAD_SUCCESS)
  118.     {
  119. sLog = "Download Failed!";
  120. g_UpdateData.SaveLog.WriteLogString(sLog, true);
  121. return nRetCode;
  122. }
  123. sLog = "Download OK!";
  124. g_UpdateData.SaveLog.WriteLogString(sLog, true);
  125. if (g_theApp.m_pfnCallBackProc)
  126.     {
  127.         g_theApp.m_pfnCallBackProc(defUPDATE_STATUS_DOWNLOADING, 100);
  128.     }
  129. if (g_theApp.m_pfnCallBackProc)
  130.     {
  131.         if (g_theApp.m_pfnCallBackProc(defUPDATE_STATUS_UPDATING, 0))
  132. {
  133. nRetCode = defUPDATE_RESULT_CANCEL;
  134. goto Exit0;
  135. }
  136.     }
  137. TRACE0("Updaten");
  138.     nRetCode = g_theApp.Update();
  139. TRACE0("Update Endn");
  140. if (g_theApp.m_pfnCallBackProc)
  141.     {
  142.         g_theApp.m_pfnCallBackProc(defUPDATE_STATUS_UPDATING, 100);
  143.     }
  144. Exit0: 
  145.     return nRetCode;
  146. }
  147. int __stdcall Update_Cancel()
  148. {
  149. return g_theApp.CancelDownload();
  150. }