00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef INCL_UPDATER
00037 #define INCL_UPDATER
00038
00039 #include "base/globalsdef.h"
00040 #include "base/fscapi.h"
00041 #include "spdm/ManagementNode.h"
00042 #include "spdm/DMTreeFactory.h"
00043 #include "spdm/DMTree.h"
00044 #include "base/util/utils.h"
00045 #include "base/util/StringBuffer.h"
00046
00047 #include "updater/UpdaterConfig.h"
00048 #include "updater/UpdaterUI.h"
00049
00050 #define UP_URL_COMPONENT "component="
00051 #define UP_URL_VERSION "version="
00052 #define UP_URL_FORMAT "format="
00053
00054 #define UP_TYPE "type="
00055 #define UP_ACTIVATION_DATE "activation-date="
00056 #define UP_SIZE "size="
00057 #define UP_VERSION "version="
00058 #define UP_URL_UPDATE "url="
00059 #define UP_URL_COMMENT "url_description="
00060
00061
00062 #define UP_PROPERTIES "properties"
00063
00064
00065 #define UP_TYPE_OPTIONAL "optional"
00066 #define UP_TYPE_RECOMMENDED "recommended" // This is the default
00067 #define UP_TYPE_MANDATORY "mandatory"
00068
00069
00070 BEGIN_NAMESPACE
00071
00076 class Updater {
00077
00078 private:
00079
00081 StringBuffer component;
00082
00084 StringBuffer version;
00085
00087 time_t currentTime;
00088
00090 time_t nextCheckTime;
00091
00093 time_t nextRemindTime;
00094
00099 UpdaterConfig& config;
00100
00102 UpdaterUI* ui;
00103
00104 private:
00105
00111 int32_t requestUpdate();
00112
00117 int32_t parseMessage(StringBuffer message);
00118
00122 StringBuffer long2string(uint32_t v) ;
00123
00127 uint32_t string2long(const StringBuffer& v) ;
00128
00132 void getListedString(ArrayList& allString, const StringBuffer& s,
00133 const StringBuffer& separator);
00134
00135
00141 int32_t buildVersionID(const StringBuffer& version);
00142
00143 public:
00144
00148 Updater(const StringBuffer& component, const StringBuffer& version, UpdaterConfig& c);
00149
00150 ~Updater();
00151
00159 bool start();
00160
00167 void forceUpdate();
00168
00174 bool isNewVersionAvailable();
00175
00191 bool newVersionAvailable(bool onlyMandatoryExpired = false);
00192
00198 void setUI(UpdaterUI* ui);
00199
00205 bool checkIsToUpdate();
00206
00214 bool isMandatoryUpdateActivationDateExceeded();
00215
00216 };
00217
00218 END_NAMESPACE
00219
00220 #endif
00221