00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00036 #include <stdio.h>
00037 #include <stdlib.h>
00038 #include <string.h>
00039
00040 #include "erregapi.h"
00041 #include "erregbasis.h"
00042 #include "erregnwprofiles.h"
00043 #include "erreglog.h"
00044
00045 static void getAllSettings(void);
00046 static gboolean setAllSettings(void);
00047
00048 static void testPCProfiles(void);
00049 static void testNetworkProfiles(void);
00050
00051 static gboolean exportConfig(void);
00052 static gboolean importConfig(void);
00053
00054 static void testValidation(void);
00055
00056 static void testMinSet(void);
00057
00058 static void testTimeConsumption(void);
00059
00060 int main()
00061 {
00062 gboolean bRet;
00063
00064
00065 bRet = erRegRWLockInit();
00066 if (FALSE == bRet)
00067 {
00068 ERREG_ERRORPRINTF("error");
00069 return 0;
00070 }
00071
00072 getAllSettings();
00073
00074
00075 bRet = setAllSettings();
00076
00077
00078 testPCProfiles();
00079
00080
00081 testNetworkProfiles();
00082
00083
00084 exportConfig();
00085
00086
00087 importConfig();
00088
00089
00090 testValidation();
00091
00092
00093 testMinSet();
00094
00095
00096 testTimeConsumption();
00097
00098
00099 erRegRWLockDestroy();
00100
00101 return 0;
00102 }
00103
00104 static void getAllSettings(void)
00105 {
00106
00107 gboolean bRet;
00108 regLoad_t ret;
00109
00110
00111 bRet = erRegReadLock();
00112 if (FALSE == bRet)
00113 {
00114 ERREG_ERRORPRINTF("error");
00115 return;
00116 }
00117
00118
00119 ret = erRegLoad(regBasis_t);
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 regVersion_t *theVersion = erRegGetVersion();
00131 erRegFreeVersion(theVersion);
00132 theVersion = NULL;
00133
00134 regUserProfile_t *theUserProfile = erRegGetUserProfile();
00135 erRegFreeUserProfile(theUserProfile);
00136 theUserProfile = NULL;
00137
00138 regUserSetting_t *theUserSetting = erRegGetUserSetting();
00139 erRegFreeUserSetting(theUserSetting);
00140 theUserSetting = NULL;
00141
00142 regPCConfig_t *thePCConfig = NULL;
00143 regPCProfile_t **thePCs = NULL;
00144 erRegGetPCProfiles(&thePCConfig, &thePCs);
00145 erRegFreePCProfiles(thePCConfig, thePCs);
00146 thePCConfig = NULL;
00147 thePCs = NULL;
00148
00149 regAutoConnect_t *theAutoConnect = erRegGetAutoConnect();
00150 erRegFreeAutoConnect(theAutoConnect);
00151 theAutoConnect = NULL;
00152
00153 regContentCategory_t *theContentCategory = erRegGetContentCategory(BOOKS_CATEGORY);
00154 erRegFreeContentCategory(theContentCategory);
00155 theContentCategory = NULL;
00156
00157 theContentCategory = erRegGetContentCategory(NEWSPAPERS_CATEGORY);
00158 erRegFreeContentCategory(theContentCategory);
00159 theContentCategory = NULL;
00160
00161 theContentCategory = erRegGetContentCategory(NOTES_CATEGORY);
00162 erRegFreeContentCategory(theContentCategory);
00163 theContentCategory = NULL;
00164
00165 theContentCategory = erRegGetContentCategory(DOCUMENTS_CATEGORY);
00166 erRegFreeContentCategory(theContentCategory);
00167 theContentCategory = NULL;
00168
00169 theContentCategory = erRegGetContentCategory(MAIN_CATEGORY);
00170 erRegFreeContentCategory(theContentCategory);
00171 theContentCategory = NULL;
00172
00173 theContentCategory = erRegGetContentCategory(SD_CATEGORY);
00174 erRegFreeContentCategory(theContentCategory);
00175 theContentCategory = NULL;
00176
00177 theContentCategory = erRegGetContentCategory(USB_CATEGORY);
00178 erRegFreeContentCategory(theContentCategory);
00179 theContentCategory = NULL;
00180
00181 theContentCategory = erRegGetContentCategory(MODE_CATEGORY);
00182 erRegFreeContentCategory(theContentCategory);
00183 theContentCategory = NULL;
00184
00185 theContentCategory = erRegGetContentCategory(DOWNLOAD_HISTORY);
00186 erRegFreeContentCategory(theContentCategory);
00187 theContentCategory = NULL;
00188
00189 theContentCategory = erRegGetContentCategory(SEARCH_RESULT);
00190 erRegFreeContentCategory(theContentCategory);
00191 theContentCategory = NULL;
00192
00193 theContentCategory = erRegGetContentCategory(RECENTDOCUMENTS);
00194 erRegFreeContentCategory(theContentCategory);
00195 theContentCategory = NULL;
00196
00197 regLastRead_t *theLastRead = erRegGetLastRead(BOOKS_CATEGORY);
00198 erRegFreeLastRead(theLastRead);
00199 theLastRead = NULL;
00200
00201 theLastRead = erRegGetLastRead(NEWSPAPERS_CATEGORY);
00202 erRegFreeLastRead(theLastRead);
00203 theLastRead = NULL;
00204
00205 theLastRead = erRegGetLastRead(DOCUMENTS_CATEGORY);
00206 erRegFreeLastRead(theLastRead);
00207 theLastRead = NULL;
00208
00209 theLastRead = erRegGetLastRead(NOTES_CATEGORY);
00210 erRegFreeLastRead(theLastRead);
00211 theLastRead = NULL;
00212
00213 regUserAppList_t *theUserAppList = NULL;
00214 regUserApp_t *theUserApp = NULL;
00215 int i;
00216 theUserAppList = erRegGetUserAppList();
00217 if (theUserAppList)
00218 {
00219 for (i = 0; i < theUserAppList->uaIDArraySize; i++)
00220 {
00221 theUserApp = erRegGetUserApp(theUserAppList->uaIDArray[i]);
00222 erRegFreeUserApp(theUserApp);
00223 theUserApp = NULL;
00224 }
00225 }
00226 erRegFreeUserAppList(theUserAppList);
00227 theUserAppList = NULL;
00228
00229
00231 {
00232 static const char * extTable [] =
00233 {
00234 "pdf",
00235 "eba",
00236 "xeb",
00237 "xhtml",
00238 "html",
00239 "txt",
00240 "jpg",
00241 "jpeg",
00242 "png",
00243 "bmp",
00244 0,
00245 };
00246 static const int extTableSize = sizeof(extTable)/sizeof(extTable[0]);
00247 int index = 0;
00248 for(; index < extTableSize; ++index)
00249 {
00250 regExtInfoList_t *theExtInfoList = erRegGetExtInfoList((char *)extTable[index]);
00251 erRegFreeExtInfoList(theExtInfoList);
00252 theExtInfoList = NULL;
00253 }
00254 }
00255
00256 regStartUp_t *theStartUp = erRegGetStartUp();
00257 erRegFreeStartUp(theStartUp);
00258 theStartUp = NULL;
00259
00260
00261 erRegUnload(regBasis_t);
00262
00263
00264 ret = erRegLoad(regNWProfiles_t);
00265
00266 regNetworkConfig_t *theNetworkConfig = NULL;
00267 regNetworkProfile_t **theNetworks = NULL;
00268 erRegGetNetworkProfiles(&theNetworkConfig, &theNetworks);
00269 erRegFreeNetworkProfiles(theNetworkConfig, theNetworks);
00270 theNetworkConfig = NULL;
00271 theNetworks = NULL;
00272
00273 regLastConnect_t *theLastConnect = erRegGetLastConnect();
00274 erRegFreeLastConnect(theLastConnect);
00275 theLastConnect = NULL;
00276
00277 erRegGetAutoConnectWlan();
00278
00279 erRegUnload(regNWProfiles_t);
00280
00281
00282 ret = erRegLoad(regToolbar_t);
00283 if (loadOk_t == ret)
00284 {
00285 regIconSet_t *theIconSet = erRegGetIconSet();
00286 erRegFreeIconSet(theIconSet);
00287 theIconSet = NULL;
00288 }
00289 erRegUnload(regToolbar_t);
00290
00291
00292 erRegUnlock();
00293 }
00294
00295 static gboolean setAllSettings(void)
00296 {
00297 return FALSE;
00298
00299 regLoad_t ret;
00300 gboolean bRet;
00301
00302
00303 bRet = erRegWriteLock();
00304 if (FALSE == bRet)
00305 {
00306 ERREG_ERRORPRINTF("error");
00307 return FALSE;
00308 }
00309
00310
00311 ret = erRegLoad(regBasis_t);
00312 if (loadError_t == ret)
00313 {
00314 ERREG_ERRORPRINTF("error");
00315 erRegUnlock();
00316 return FALSE;
00317 }
00318
00545 }
00546
00547
00548
00549
00550
00551 static void testPCProfiles(void)
00552 {
00553 return;
00554
00555 regPCConfig_t *pPCConfig = NULL;
00556 regPCProfile_t **pPCs = NULL;
00557
00558 gboolean bRet;
00559 regLoad_t ret;
00560
00561
00562 bRet = erRegWriteLock();
00563 if (FALSE == bRet)
00564 {
00565 ERREG_ERRORPRINTF("error");
00566 return;
00567 }
00568
00569
00570 ret = erRegLoad(regBasis_t);
00571 if (loadError_t == ret)
00572 {
00573 ERREG_ERRORPRINTF("error");
00574 erRegUnlock();
00575 return;
00576 }
00577
00578
00579 erRegGetPCProfiles(&pPCConfig, &pPCs);
00580 if (pPCConfig && pPCs)
00581 {
00582 int index;
00583 regPCProfile_t *thePCProfile = NULL;
00584
00585
00586
00587
00588 thePCProfile = erRegDupPCProfile(pPCs[0]);
00589
00590 if (thePCProfile->username)
00591 {
00592 g_free(thePCProfile->username);
00593 thePCProfile->username = g_strdup("alice123");
00594 }
00595
00596 erRegAddPCProfileToList(&pPCConfig, &pPCs, thePCProfile);
00597
00598
00599
00600
00601 erRegDeletePCProfileFromList(&pPCConfig, &pPCs, pPCConfig->pcList[(pPCConfig->size) / 2]);
00602
00603
00604 thePCProfile = erRegGetPCProfileFromList(pPCConfig, pPCs, pPCConfig->pcList[(pPCConfig->size) / 2], &index);
00605
00606
00607 if (thePCProfile->username)
00608 {
00609 g_free(thePCProfile->username);
00610 thePCProfile->username = g_strdup("tom");
00611 }
00612 if (thePCProfile->password)
00613 {
00614 g_free(thePCProfile->password);
00615 thePCProfile->password = g_strdup("qwerty");
00616 }
00617
00618 erRegSetPCProfileDefault(&pPCConfig, &pPCs, pPCConfig->pcList[(pPCConfig->size) / 2]);
00619
00620
00621
00622 const regPCProfile_t **p = (const regPCProfile_t **)pPCs;
00623 erRegSetPCProfiles(pPCConfig, p);
00624
00625
00626 erRegFreePCProfiles(pPCConfig, pPCs);
00627 }
00628
00629
00630 erRegStore();
00631
00632
00633 erRegUnload(regBasis_t);
00634
00635
00636 erRegUnlock();
00637 }
00638
00639
00640
00641
00642
00643 static void testNetworkProfiles(void)
00644 {
00645 return;
00646
00647 regNetworkConfig_t *pNetworkConfig = NULL;
00648 regNetworkProfile_t **pNetworks = NULL;
00649
00650 gboolean bRet;
00651 regLoad_t ret;
00652
00653
00654 bRet = erRegWriteLock();
00655 if (FALSE == bRet)
00656 {
00657 ERREG_ERRORPRINTF("error");
00658 return;
00659 }
00660
00661
00662 ret = erRegLoad(regNWProfiles_t);
00663 if (loadError_t == ret)
00664 {
00665 ERREG_ERRORPRINTF("error");
00666 erRegUnlock();
00667 return;
00668 }
00669
00670
00671 erRegGetNetworkProfiles(&pNetworkConfig, &pNetworks);
00672 if (pNetworkConfig && pNetworks)
00673 {
00674 int index;
00675 regNetworkProfile_t *theNetworkProfile = NULL;
00676
00677
00678
00679
00680 theNetworkProfile = erRegDupNetworkProfile(pNetworks[0]);
00681
00682 if (theNetworkProfile->name)
00683 {
00684 g_free(theNetworkProfile->name);
00685 theNetworkProfile->name = g_strdup("Network Environment At Home");
00686 }
00687
00688
00689 erRegAddNetworkProfileToList(&pNetworkConfig, &pNetworks, theNetworkProfile);
00690
00691
00692
00693
00694 erRegDeleteNetworkProfileFromList(&pNetworkConfig, &pNetworks,
00695 pNetworkConfig->networkList[(pNetworkConfig->size) / 2]);
00696
00697
00698 index = erRegGetNetworkProfileFromList(pNetworkConfig,
00699 pNetworkConfig->networkList[(pNetworkConfig->size) / 2]);
00700 theNetworkProfile = pNetworks[index];
00701 if (theNetworkProfile->name)
00702 {
00703 g_free(theNetworkProfile->name);
00704 theNetworkProfile->name = g_strdup("Network Environment At Office");
00705 }
00706
00707
00708 erRegSetNetworkProfileDefault(&pNetworkConfig, &pNetworks,
00709 pNetworkConfig->networkList[(pNetworkConfig->size) / 2]);
00710
00711
00712
00713
00714
00715 const regNetworkProfile_t **p = (const regNetworkProfile_t **)pNetworks;
00716 erRegSetNetworkProfiles(pNetworkConfig, p);
00717
00718
00719 erRegFreeNetworkProfiles(pNetworkConfig, pNetworks);
00720 }
00721
00722
00723 erRegStore();
00724
00725
00726 erRegUnload(regNWProfiles_t);
00727
00728
00729 erRegUnlock();
00730 }
00731
00732 static gboolean exportConfig(void)
00733 {
00734 return FALSE;
00735
00736 gboolean bRet;
00737
00738 bRet = erRegWriteLock();
00739 if (FALSE == bRet)
00740 {
00741 return FALSE;
00742 }
00743
00744
00745
00746 erRegUnlock();
00747
00748 return bRet;
00749 }
00750
00751 static gboolean importConfig(void)
00752 {
00753 return FALSE;
00754
00755 gboolean bRet;
00756
00757 bRet = erRegWriteLock();
00758 if (FALSE == bRet)
00759 {
00760 return FALSE;
00761 }
00762
00763
00764
00765 erRegUnlock();
00766
00767 return bRet;
00768 }
00769
00770 static void testValidation(void)
00771 {
00772 return;
00773 gboolean bRet;
00774 regLoad_t ret;
00775
00776 bRet = erRegWriteLock();
00777 if (FALSE == bRet)
00778 {
00779 return;
00780 }
00781
00782 ret = erRegLoad(regBasis_t);
00783 if (loadError_t == ret)
00784 {
00785 ERREG_ERRORPRINTF("error");
00786 erRegUnlock();
00787 return;
00788 }
00789
00790
00791 regUserProfile_t *theUserProfile = erRegGetUserProfile();
00792 if (theUserProfile->password)
00793 {
00794 g_free(theUserProfile->password);
00795 theUserProfile->password = g_strdup("1234567890");
00796 }
00797 erRegSetUserProfile(theUserProfile);
00798 erRegFreeUserProfile(theUserProfile);
00799
00800 erRegStore();
00801
00802
00803 regLastRead_t *theLastRead = erRegGetLastRead(BOOKS_CATEGORY);
00804 bRet = erRegSetLastRead("yehong", theLastRead);
00805 erRegFreeLastRead(theLastRead);
00806
00807 erRegStore();
00808
00809 erRegUnload(regBasis_t);
00810 erRegUnlock();
00811 }
00812
00813 static void testMinSet(void)
00814 {
00815 return;
00816 gboolean bRet;
00817
00818 bRet = erRegWriteLock();
00819 if (FALSE == bRet)
00820 {
00821 return;
00822 }
00823
00896 }
00897
00898 static void testTimeConsumption(void)
00899 {
00900 return;
00901
00902
00903 gboolean bRet = erRegReadLock();
00904 if (FALSE == bRet)
00905 {
00906 ERREG_ERRORPRINTF("error");
00907 return;
00908 }
00909
00910 ERREG_TIMEDISPLAY("Begin loading registry");
00911
00912
00913 regLoad_t ret = erRegLoad(regBasis_t);
00914 if (loadError_t == ret)
00915 {
00916 ERREG_ERRORPRINTF("error");
00917 erRegUnlock();
00918 return;
00919 }
00920
00921 erRegUnload(regBasis_t);
00922
00923 ret = erRegLoad(regNWProfiles_t);
00924 regNetworkConfig_t *theNetworkConfig = NULL;
00925 regNetworkProfile_t **theNetworks = NULL;
00926 erRegGetNetworkProfiles(&theNetworkConfig, &theNetworks);
00927 erRegFreeNetworkProfiles(theNetworkConfig, theNetworks);
00928 theNetworkConfig = NULL;
00929 theNetworks = NULL;
00930 erRegUnload(regNWProfiles_t);
00931
00932 ret = erRegLoad(regToolbar_t);
00933 regIconSet_t *theIconSet = erRegGetIconSet();
00934 erRegFreeIconSet(theIconSet);
00935 theIconSet = NULL;
00936 erRegUnload(regToolbar_t);
00937
00938 ERREG_TIMEDISPLAY("End loading registry");
00939
00940
00941 erRegUnlock();
00942 }
00943