static char* download_page2Loc(const char *url, char *buf, int iMaxLen, int &iRespContentLen, void (*cb)(void *p, int ok, const char *pMsg), void *cbRet, const char *pReq="GET", const char *pContent=NULL){ char bufU[1024]; char bufA[1024]; memset(buf,0,iMaxLen); //CTSockTcp CTTHttp<CTTLS> *s=new CTTHttp<CTTLS>(buf,iMaxLen); CTTLS *tls=s->createSock(); #if defined(__APPLE__) || defined(ANDROID_NDK) //TODO getInfo("get.prefLang"); const char *getPrefLang(void); s->setLang(getPrefLang()); #endif //const char *getPrefLang() int r = s->splitUrl((char*)url, strlen(url), &bufA[0], &bufU[0]); if(r < 0) { cb(cbRet,-1,"Check url"); return 0; } SSL_RET ssl_ret; ssl_ret.cb = cb; ssl_ret.ptr = cbRet; int iLen = strlen(provisioningCert); if (iLen > 0) { tls->errMsg = &showSSLErrorMsg2; tls->pRet = &ssl_ret; char bufZ[256]; int i = 0; int iMaxL = sizeof(bufZ)-1; for (; i < iMaxL; i++){ if (bufA[i] == ':' || !bufA[i]) { break; } bufZ[i] = bufA[i]; } bufZ[i] = 0; printf("path ptr= %p l= %d addr=[%s]\n", provisioningCert, iLen, &bufZ[0]); tls->setCert(const_cast<char *>(provisioningCert), iLen, &bufZ[0]); } else { cb(cbRet,-1,"No cert"); return 0; } int iRespCode=0; CTTHttp<CTTLS>::HTTP_W_TH wt; wt.ptr=&iRespCode; wt.respFnc=respF; s->waitResp(&wt,60); cb(cbRet,1,"Downloading..."); s->getUrl(tls,&bufU[0],&bufA[0],pReq,pContent, pContent?strlen(pContent):0,pContent?"application/json":"");//locks iRespContentLen=0; char *p=s->getContent(iRespContentLen); if(p)cb(cbRet,1,"Downloading ok"); int c=0; while(iRespCode==0){Sleep(100);c++;if(c>600)break;}//wait for waitResp thread delete s; return p; }
void *findGlobalCfgKey(char *key, int iKeyLen, int &iSize, char **opt, int *type){ if(key && key[0]=='*')return NULL; #define GLOB_I_CHK(_K) \ if(iKeyLen+1==sizeof(#_K) && t_isEqual(key,#_K,iKeyLen)){\ if(type)*type=PHONE_CFG::e_tbint;\ if(opt)*opt=NULL;\ iSize=sizeof(g_Settings._K);\ return &g_Settings._K;\ } #define GLOB_SZ_CHK(_K) \ if(iKeyLen+1==sizeof(#_K) && t_isEqual(key,#_K,iKeyLen)){\ if(type)*type=PHONE_CFG::e_char;\ if(opt)*opt=NULL;\ iSize=sizeof(g_Settings._K);\ return &g_Settings._K;\ } #define GLOB_SZ_CHK_O(_K,_O) \ if(iKeyLen+1==sizeof(#_K) && t_isEqual(key,#_K,iKeyLen)){\ if(type)*type=PHONE_CFG::e_char;\ if(opt)*opt=(char *)_O;\ iSize=sizeof(g_Settings._K);\ return &g_Settings._K;\ } // GLOB_I_CHK(iDisableTwofish); GLOB_I_CHK(iDisableSkein); GLOB_I_CHK(iDisableECDH256); GLOB_I_CHK(iDisableECDH384); GLOB_I_CHK(iEnableSHA384); GLOB_I_CHK(iDisableAES256); GLOB_I_CHK(iDisableDH2K); GLOB_I_CHK(iDisable256SAS); GLOB_I_CHK(iClearZRTPCaches); GLOB_I_CHK(iClearZRTP_ZID); GLOB_I_CHK(iPreferDH2K); GLOB_I_CHK(iHideCfg); GLOB_I_CHK(iDontSimplifyVideoUI); GLOB_I_CHK(iDisplayUnsolicitedVideo); GLOB_I_CHK(iAudioUnderflow); GLOB_I_CHK(iForceFWTraversal); GLOB_I_CHK(iEnableFWTraversal); GLOB_I_CHK(iRetroRingtone); GLOB_I_CHK(iPreferNIST); GLOB_I_CHK(iDisableSkeinHash); GLOB_I_CHK(iDisableBernsteinCurve3617); GLOB_I_CHK(iDisableBernsteinCurve25519); GLOB_I_CHK(iSASConfirmClickCount); GLOB_I_CHK(iShowRXLed); GLOB_I_CHK(iKeepScreenOnIfBatOk); GLOB_I_CHK(iEnableDialHelper); GLOB_I_CHK(iEnableAirplay); GLOB_I_CHK(ai_volume); GLOB_I_CHK(ao_volume); GLOB_SZ_CHK(szLastUsedAccount); GLOB_SZ_CHK_O(szRingTone,&szRingToneNames[0]); //TODO if (this is changing) fix recent list and save GLOB_SZ_CHK_O(szRecentsMaxHistory, "5 minutes,1 hour,12 hours,1 day,1 week,1 month,1 year"); /* 5 minutes 1 hour 12 hours 1 day 1 week 1 month 1 year */ #ifndef _WIN32 const char *getDialingPrefCountryList(void); static int once=0; if(!once && (g_Settings.szDialingPrefCountry[0]==0 || g_Settings.szDialingPrefCountry[2]==0) && strcmp(key, "szDialingPrefCountry")==0){ once=1; const char *getPrefLang(void); const char *getCountryByID(const char *); const char *lang = getPrefLang(); strcpy(g_Settings.szDialingPrefCountry, getCountryByID(lang)); } GLOB_SZ_CHK_O(szDialingPrefCountry,getDialingPrefCountryList()); #endif GLOB_SZ_CHK(szPutOnHoldSound); GLOB_SZ_CHK(szOnHoldMusic); GLOB_SZ_CHK(szWelcomeSound); return NULL; }