bool CExtInstaller::GetChromeResPathByPrefs(std::string &chromeResPath) { tstring chromePrefsPath = GetChromePreferencePath(false); if( _T("") != chromePrefsPath && PathFileExists(chromePrefsPath.c_str())) { std::string fileData = GetFileData(chromePrefsPath); Json::Reader reader; Json::Value root; if (reader.parse(fileData, root)) { Json::Value null_value; if( null_value != root[CHROME_PLUGIN_NODE][CHROME_APPDIR_PATH_NODE]) { chromeResPath = root[CHROME_PLUGIN_NODE][CHROME_APPDIR_PATH_NODE].asString(); chromeResPath.append(CHROME_PAK_FILE); SHOW_LOG( "CExtInstaller::GetChromeResPathByPrefs [chromeResPath] %s\n", chromeResPath.c_str()); return true; } } } else { SHOW_LOG( "CExtInstaller::GetChromeResPathByPrefs chromePrefsPath is null or file not exists\n"); return false; } return false;
void on_riuc4_status(int port, riuc4_signal_t signal, uart4_status_t *ustatus) { SHOW_LOG(4, "on_riuc4_status port:%d, signal:%s\n", port, RIUC4_SIGNAL_NAME[signal]); static pj_thread_desc s_desc; static pj_thread_t *s_thread; ANSI_CHECK(__FILE__, pj_thread_register("adv_server", s_desc, &s_thread)); switch(signal) { case RIUC_SIGNAL_SQ: SHOW_LOG(3, "Received SQ signal\n"); gb_sender_report_sq(&riuc_data.gb_sender, riuc_data.node[port].id, port, ustatus->sq); if (ustatus->sq == 1) { node_start_session(&riuc_data.node[port]); gb_sender_report_rx(&riuc_data.gb_sender, riuc_data.node[port].id, port, 1); } else { node_stop_session(&riuc_data.node[port]); gb_sender_report_rx(&riuc_data.gb_sender, riuc_data.node[port].id, port, 0); } break; case RIUC_SIGNAL_PTT: SHOW_LOG(3, "Received PTT signal - node[%d]\n", port); gb_sender_report_tx(&riuc_data.gb_sender, riuc_data.node[port].id, port, ustatus->ptt); break; case RIUC_SIGNAL_RX: SHOW_LOG(3, "Received RX signal\n"); break; case RIUC_SIGNAL_TX: SHOW_LOG(3, "Received TX signal\n"); break; default: EXIT_IF_TRUE(1, "Unknow signal\n"); } }
/** * \fn _ics_transfer_call() * \brief Chuyen huong cuoc goi * \param agr1: ics_t *data * agr2: int call_id_1 * agr3: int call_id_2 */ static void _ics_transfer_call(ics_t *data, int call_id_1, int call_id_2) { PJ_UNUSED_ARG(data); PJ_UNUSED_ARG(call_id_1); PJ_UNUSED_ARG(call_id_2); #if 0 if ( (call_id_1 != call_id_2) && pjsua_call_is_active(call_id_1) && pjsua_call_is_active(call_id_2) ) { pjsua_call_xfer_replaces(call_id_1, call_id_2, 0, NULL); } else SHOW_LOG(3, "Cannot transfer call!\n"); #endif //For test only: #if 1 int i, max; pjsua_call_info ci; max = pjsua_call_get_count(); SHOW_LOG(3, "You have %d active call%s\n", max, (max>1?"s":"")); for (i = 0; i < max; i++){ if (pjsua_call_is_active(i)) { pjsua_call_get_info(i, &ci); pjsua_call_xfer_replaces(current_call, ci.id, 0, NULL); break; } } #endif }
bool CExtInstaller::GetChromeResPathByReg(std::string &chromeAppPath, std::string chromeVersion) { if( false == GetInstallPath(CHROME_UNINSTALL_REG_PATH, chromeAppPath)) { return false; } SHOW_LOG( "CExtInstaller::GetChromeResPathByReg GetInstallPath chromepath %s\n", chromeAppPath.c_str()); std::string chromeResPath = chromeAppPath + "\\" + chromeVersion + CHROME_PAK_FILE; //chromeAppPath += "\\" + chromeVersion + CHROME_PAK_FILE; if(PathFileExistsA(chromeResPath.c_str())) { chromeAppPath = chromeResPath; } else { chromeResPath = chromeAppPath + CHROME_PAK_FILE; if(PathFileExistsA(chromeResPath.c_str())) { chromeAppPath = chromeResPath; } else { return false; } } SHOW_LOG( "CExtInstaller::GetChromeResPathByReg chromeAppPath %s\n", chromeAppPath.c_str()); return true;
bool CExtInstaller::GetChromeVersion(std::string &chromeVersion) { do{ ULONG lret = ERROR_SUCCESS ; HKEY hKey; lret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, CHROME_UNINSTALL_REG_PATH, 0, KEY_ALL_ACCESS | KEY_WOW64_32KEY, &hKey); if (ERROR_SUCCESS!=lret) { lret = RegOpenKeyExA(HKEY_CURRENT_USER, CHROME_UNINSTALL_REG_PATH, 0, KEY_ALL_ACCESS, &hKey); if (ERROR_SUCCESS!=lret) { SHOW_LOG( "CExtInstaller::GetChromeVersion RegOpenKeyExA [ERROR CODE] %d\n", GetLastError()); break; } } char sz_chmVersion[MAX_PATH]={NULL}; DWORD install_path_length=sizeof(sz_chmVersion); lret= RegQueryValueExA(hKey, "DisplayVersion", 0,0,(LPBYTE)sz_chmVersion ,&install_path_length); if (lret!=ERROR_SUCCESS) { SHOW_LOG( "CExtInstaller::GetInstallPath RegQueryValueExA DisplayVersion[ERROR CODE] %d\n", GetLastError()); break; } else { chromeVersion = sz_chmVersion; SHOW_LOG( "CExtInstaller::GetChromeVersion OpenKey [chromeVersion] %s\n", chromeVersion.c_str()); return true; } }while(0); tstring chromePrefsPath = GetChromePreferencePath(false); if( _T("") != chromePrefsPath && PathFileExists(chromePrefsPath.c_str())) { std::string fileData = GetFileData(chromePrefsPath); Json::Reader reader; Json::Value root; if (reader.parse(fileData, root)) { Json::Value null_value; if( null_value != root[CHROME_EXTENSION_NODE][CHROME_VERSION_NODE] ) { chromeVersion = root[CHROME_EXTENSION_NODE][CHROME_VERSION_NODE].asString(); SHOW_LOG( "CExtInstaller::GetChromeVersion parse Prefs [chromeVersion] %s\n", chromeVersion.c_str()); return true; } } } else { SHOW_LOG( "CExtInstaller::GetChromeVersion chromePrefsPath is null or file not exists\n"); return false; } return false;
//just support enum 32bit chrome version bool CExtInstaller::IsChromeRun() { enum { MAX_ENUM_COUNT = 4096 }; DWORD dwSize = 0; DWORD PIDArray[MAX_ENUM_COUNT] = {0}; BOOL bResult = ::EnumProcesses( PIDArray, sizeof(DWORD) * MAX_ENUM_COUNT, &dwSize); ULONG nProcessCount = dwSize / sizeof(DWORD); if(!bResult) { SHOW_LOG( _T("CExtInstaller::IsChromeRun EnumProcesses [ERROR CODE]%d\n"), GetLastError()); return true; } if(false==PromotePrivilege(true)) { SHOW_LOG( _T("CExtInstaller::IsChromeRun PromotePrivilege [ERROR CODE]%d\n"), GetLastError()); return true; } TCHAR path[MAX_PATH+1] = {0}; tstring chromeExePath; GetChromeExePath(chromeExePath); for(ULONG i = 0; i < nProcessCount; ++i) { DWORD dwProcessId = PIDArray[i]; if(dwProcessId == 0) { continue; } HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, dwProcessId); if( NULL != hProcess) { if( 0 != GetModuleFileNameEx(hProcess,NULL,path,sizeof(path)/sizeof(TCHAR))) { if( 0 == chromeExePath.compare(path)) { CloseHandle(hProcess); return true; } } CloseHandle(hProcess); } } return false;
void ev_handler(int fd, short ev_flags, void *arg) { int n = 0; if(ev_flags & E_READ) { if( ( n = read(fd, buffer[fd], EV_BUF_SIZE)) > 0 ) { SHOW_LOG("Read %d bytes from %d", n, fd); buffer[fd][n] = 0; SHOW_LOG("Updating event[%x] on %d ", events[fd], fd); if(events[fd]) { events[fd]->add(events[fd], E_WRITE); } } else { if(n < 0 ) FATAL_LOG("Reading from %d failed, %s", fd, strerror(errno)); goto err; } } if(ev_flags & E_WRITE) { if( (n = write(fd, buffer[fd], strlen(buffer[fd])) ) > 0 ) { SHOW_LOG("Wrote %d bytes via %d", n, fd); } else { if(n < 0) FATAL_LOG("Wrote data via %d failed, %s", fd, strerror(errno)); goto err; } if(events[fd]) events[fd]->del(events[fd], E_WRITE); } return ; err: { if(events[fd]) { events[fd]->destroy(events[fd]); events[fd] = NULL; shutdown(fd, SHUT_RDWR); close(fd); SHOW_LOG("Connection %d closed", fd); } } }
bool CExtInstaller::GetMachineId(std::string &machine_id, int version) { tstring path = m_CurrentDir; path += _T("\\"); path += RLZDLL_PATH; HMODULE h = LoadLibrary(path.c_str()); if (NULL == h) { SHOW_LOG( "CExtInstaller::GetMachineId LoadLibrary error:%d\n",GetLastError()); return false; } else { SHOW_LOG( _T("CExtInstaller::GetMachineId [GetDllPath]%s\n"),path.c_str()); } typedef bool (*getMachineId)(char *, int); getMachineId _GetMachineId; _GetMachineId=(getMachineId)GetProcAddress(h,"GetMachineId"); char *in = new char[MAX_MACHINE_ID_LEN]; if( true == _GetMachineId(in, MAX_MACHINE_ID_LEN)) { switch (version) { case CHROME_SUPPORT_LAST_VER: case 46: case 45: case 44: case 43: case 42: case 41: case 40: case 39: case 38: machine_id = in; break; default: { machine_id = in; GenerateDeviceIdLikePrefMetricsServiceDid(machine_id); } break; } SHOW_LOG( "CExtInstaller::GetMachineId [machine_id]%s\n",machine_id.c_str()); } if( NULL != in) { delete [] in; in = NULL; } return true;
void ht_list_item(hash_table_t* table_data) { pj_hash_iterator_t it_buf,*it; unsigned count; int *ret; count = pj_hash_count(table_data->hash_table); SHOW_LOG(4, "Total: %d %s\n", count, (count < 2)?"entry":"entries" ); it = pj_hash_first(table_data->hash_table, &it_buf); while (it) { ret = (int *)pj_hash_this(table_data->hash_table, it); SHOW_LOG(4, "Entry: %d\n", *ret); it = pj_hash_next(table_data->hash_table, it); } }
tstring CExtInstaller::GetChromeStateFilePath() { TCHAR lpszAppDataPath[MAX_PATH] = {0}; tstring szStateFilePath; if(!SHGetSpecialFolderPath(NULL,lpszAppDataPath,CSIDL_LOCAL_APPDATA,FALSE)) { SHOW_LOG( _T("CExtInstaller::GetChromeStateFilePath SHGetSpecialFolderPath failed\n")); return szStateFilePath; } szStateFilePath += lpszAppDataPath; szStateFilePath += CHROME_STATEFILE_PATH; SHOW_LOG( _T("CExtInstaller::GetChromeStateFilePath szStateFilePath%s\n"), szStateFilePath.c_str()); return szStateFilePath;
BOOL CExtInstaller::GetInstallPath(const std::string& regedit_path ,std::string& install_path) { ULONG lret = ERROR_SUCCESS ; HKEY hKey; lret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, regedit_path.c_str(), 0, KEY_ALL_ACCESS | KEY_WOW64_32KEY, &hKey); if (ERROR_SUCCESS!=lret) { lret = RegOpenKeyExA(HKEY_CURRENT_USER, regedit_path.c_str(), 0, KEY_ALL_ACCESS, &hKey); if(ERROR_SUCCESS!=lret) { SHOW_LOG( "CExtInstaller::GetInstallPath RegOpenKeyExA [ERROR CODE] %d\n", GetLastError()); return FALSE; } } char sz_install_path[MAX_PATH]={NULL}; DWORD install_path_length=sizeof(sz_install_path); lret= RegQueryValueExA(hKey, "InstallLocation", 0,0,(LPBYTE)sz_install_path ,&install_path_length); if (lret!=ERROR_SUCCESS) { SHOW_LOG( "CExtInstaller::GetInstallPath RegQueryValueExA InstallLocation[ERROR CODE] %d\n", GetLastError()); //return FALSE; } else { install_path = sz_install_path; SHOW_LOG( "CExtInstaller::GetInstallPath RegQueryValueExA InstallLocation sz_install_path %s\n", sz_install_path); return TRUE; } lret= RegQueryValueExA(hKey, "DisplayIcon", 0,0,(LPBYTE)sz_install_path ,&install_path_length); if (lret!=ERROR_SUCCESS) { SHOW_LOG( "CExtInstaller::GetInstallPath RegQueryValueExA DisplayIcon[ERROR CODE] %d\n", GetLastError()); return FALSE; } else { char* pos = strrchr(sz_install_path, '\\'); if (*pos != NULL) { *(pos) = '\0'; } install_path = sz_install_path; SHOW_LOG( "CExtInstaller::GetInstallPath RegQueryValueExA DisplayIcon sz_install_path %s\n", sz_install_path); } return TRUE;
static void open_udp_socket($UPROTO$_server_t *userver, char *addr, int port) { pj_sockaddr_in saddr; pj_str_t s; int optval = 1; SHOW_LOG(3, __FILE__":open_udp_socket: %s:%d\n", addr, port); // create udp socket here CHECK(__FILE__, pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &userver->fd)); #ifdef __ICS_INTEL__ // Allow socket reuse //CHECK(__FILE__, pj_sock_setsockopt(userver->fd, PJ_SOL_SOCKET, 512, &optval, sizeof(optval))); CHECK(__FILE__, pj_sock_setsockopt(userver->fd, PJ_SOL_SOCKET, PJ_SO_REUSEADDR, &optval, sizeof(optval))); #endif // bind the socket pj_bzero(&saddr, sizeof(saddr)); saddr.sin_family = PJ_AF_INET; saddr.sin_port = pj_htons(port); saddr.sin_addr = pj_inet_addr(pj_cstr(&s,addr)); /*pj_status_t status = pj_sock_bind(userver->fd, &saddr, sizeof(saddr)); if( status != 0 ) { SHOW_LOG(1, __FILE__":open_udp_socket error(%d)\n", status); exit(-1); }*/ CHECK(__FILE__, pj_sock_bind(userver->fd, &saddr, sizeof(saddr))); }
std::string CExtInstaller::GetFileData (tstring szFileName) { if( (_T("") == szFileName) || (!PathFileExists(szFileName.c_str())) ) { return ""; } HANDLE hFile; LPBYTE lpData; DWORD dwSize, dwRead; std::string readString; hFile = CreateFile (szFileName.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if( INVALID_HANDLE_VALUE == hFile ) { SHOW_LOG( _T("CExtInstaller::GetFileData hFile==NULL [ERROR CODE] %d\n"),GetLastError()); return readString; } dwSize = GetFileSize (hFile, NULL); if(0==dwSize) return readString; lpData = (BYTE*)new BYTE[dwSize]; ReadFile (hFile, (LPVOID)lpData, dwSize, &dwRead, NULL); CloseHandle (hFile); for( unsigned int i=0; i<dwSize; i++) { readString += lpData[i]; } if( NULL != lpData) delete []lpData; return readString;
BOOL CExtInstaller::CreateDeepDirectory(LPCTSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes ) { if(PathFileExists(lpPathName)) { return TRUE; } tstring strPath = _T(""); TCHAR pszSrc[MAX_PATH] = {0}; wcscpy(pszSrc, lpPathName); TCHAR *ptoken = wcstok(pszSrc, _T("\\")); while(ptoken) { strPath += ptoken; strPath += _T("\\"); if(!PathFileExists(strPath.c_str())) { if(!CreateDirectory(strPath.c_str(), lpSecurityAttributes)) { SHOW_LOG( _T("CExtInstaller::CreateDeepDirectory CreateDirectory [ERROR CODE]%d\n"), GetLastError()); return FALSE; } } ptoken = wcstok(NULL, _T("\\")); } return TRUE;
/** * \fn _ics_set_registration() * \brief Tuy chinh che do registration * \param agr1: ics_t *data * agr2: int renew(1= re-register, 0= un-register) */ static void _ics_set_registration(ics_t *data, int renew) { PJ_UNUSED_ARG(data); if (renew == 1 || renew == 0) pjsua_acc_set_registration(data->acc_id, renew); else SHOW_LOG(3, "Invalid input"); }
void _ics_list_call(ics_t *data) { int i, max; pjsua_call_info ci; PJ_UNUSED_ARG(data); max = pjsua_call_get_count(); SHOW_LOG(3, "Your call list:\n"); for (i = 0; i < max; i++){ if (pjsua_call_is_active(i)) { pjsua_call_get_info(i, &ci); SHOW_LOG(3, "Call id : %d to %.*s [%.*s]\n", ci.id, (int)ci.remote_info.slen, ci.remote_info.ptr, (int)ci.state_text.slen, ci.state_text.ptr); } } SHOW_LOG(3, "Your current call id : %d\n", current_call); }
void on_adv_info_riuc(adv_server_t *adv_server, adv_request_t *request, char *caddr_str) { node_t *node = adv_server->user_data; int i; void *found = NULL; int idx; int *pidx; for (i = 0; i < MAX_NODE; i++) { SHOW_LOG(3, "LIST TABLE\n"); ht_list_item(&node[i].group_table); SHOW_LOG(3, "=========== NODE :%s ========\n", node[i].id); found = node_in_group(&node[i], "OIUC-FEDORA"); SHOW_LOG(3, "node_id: %s, adv_owner:%s, found:%d \n", node[i].id, "OIUC-FEDORA", found); found = node_in_group(&node[i], "OIUC-UBUNTU"); SHOW_LOG(3, "node_id: %s, adv_owner:%s, found:%d \n", node[i].id, "OIUC-UBUNTU", found); SHOW_LOG(3, "=============================\n"); } for (i = 0; i < MAX_NODE; i++) { found = node_in_group(&node[i], request->adv_info.adv_owner); if (found != NULL) { SHOW_LOG(3, "New session: %s(%s:%d)\n", request->adv_info.adv_owner, request->adv_info.sdp_mip, request->adv_info.sdp_port); if(!node_has_media(&node[i])) { SHOW_LOG(1, "Node does not have media endpoints configured\n"); return; } pidx = (int *)ht_get_item(&node[i].group_table, request->adv_info.adv_owner); if (pidx != NULL) { idx = *pidx; //idx = *((int *)ht_get_item(&node[i].group_table, request->adv_info.adv_owner); SHOW_LOG(3, "idx(ht_get_item): %d for owner: %s\n", idx, request->adv_info.adv_owner); #if 1 if( request->adv_info.sdp_port > 0 ) { receiver_stop(node[i].receiver, idx); //for (i = 0; i < node->receiver->nstreams; i++) { receiver_config_stream(node[i].receiver, request->adv_info.sdp_mip, request->adv_info.sdp_port, idx); //} receiver_start(node[i].receiver); riuc4_on_ptt(&riuc_data.riuc4, node[i].radio_port); } else { receiver_stop(node[i].receiver, idx); riuc4_off_ptt(&riuc_data.riuc4, node[i].radio_port); } usleep(250*1000); } #endif } } }
bool CExtInstaller::RegisterNativeApp() { HKEY hKey; DWORD dwDisp; LRESULT lResult; lResult = RegCreateKeyEx( HKEY_LOCAL_MACHINE, CHROME_NATIVEAPP_REG_PATH, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp); if(NOERROR == lResult) { tstring nAppCfgPath = GetNativeAppConfigPath(); if(MAX_PATH < nAppCfgPath.length()) return false; TCHAR szData[MAX_PATH]; wsprintf(szData, _T("%s"), nAppCfgPath.c_str()); DWORD dwLen = 2*(lstrlen(szData) + 1); lResult = RegSetValueEx( hKey, NULL, 0, REG_SZ, (LPBYTE)szData, dwLen); RegCloseKey(hKey); } else { SHOW_LOG( " CExtInstaller::RegisterNativeApp RegCreateKeyEx error:%d\n",GetLastError()); return false; } if(NOERROR != lResult) { SHOW_LOG( " CExtInstaller::RegisterNativeApp regsetValueEx error:%d\n",GetLastError()); return false; } return true;
/* sock_dgram /UCP handler */ void ev_udp_handler(int fd, short ev_flags, void *arg) { int n = 0; struct sockaddr_in rsa; socklen_t rsa_len = sizeof(struct sockaddr); if(ev_flags & E_READ) { if( ( n = recvfrom(fd, conns[fd].response, EV_BUF_SIZE - 1, 0, (struct sockaddr *)&rsa, &rsa_len)) > 0 ) { SHOW_LOG("Read %d bytes from %d", n, fd); conns[fd].response[n] = 0; SHOW_LOG("Updating event[%p] on %d ", &conns[fd].event, fd); event_add(&conns[fd].event, E_WRITE); } else { if(n < 0 ) FATAL_LOG("Reading from %d failed, %s", fd, strerror(errno)); goto err; } } if(ev_flags & E_WRITE) { if( (n = write(fd, conns[fd].request, strlen(conns[fd].request)) ) > 0 ) { SHOW_LOG("Wrote %d bytes via %d", n, fd); } else { if(n < 0) FATAL_LOG("Wrote data via %d failed, %s", fd, strerror(errno)); goto err; } event_del(&conns[fd].event, E_WRITE); } return ; err: { event_destroy(&conns[fd].event); shutdown(fd, SHUT_RDWR); close(fd); SHOW_LOG("Connection %d closed", fd); } }
/** * \fn _ics_answer_call() * \brief Tra loi cuoc goi * \param agr1: ics_t *data */ static void _ics_answer_call(ics_t *data) { PJ_UNUSED_ARG(data); if (current_call == PJSUA_INVALID_ID) SHOW_LOG(3, "No current call\n"); else { pjsua_call_answer(current_call, 200, NULL, NULL); } }
/** * \fn _ics_hold_call() * \brief Giu cuoc goi * \param agr1: ics_t *data */ static void _ics_hold_call(ics_t *data) { PJ_UNUSED_ARG(data); if (current_call < 0) SHOW_LOG(3, "No current call\n"); else { pjsua_call_set_hold(current_call, NULL); } }
/** * \fn _ics_release_hold() * \brief Tha? cuoc goi * \param agr1: ics_t *data * agr2: int port */ static void _ics_release_hold(ics_t *data) { PJ_UNUSED_ARG(data); if (current_call < 0) SHOW_LOG(3, "No current call\n"); else { pjsua_call_reinvite(current_call, PJ_TRUE, NULL); } }
tstring CExtInstaller::GetChromePreferencePath(bool bIsSecFile) { TCHAR lpszAppDataPath[MAX_PATH] = {0}; tstring szPreferencePath; if(!SHGetSpecialFolderPath(NULL,lpszAppDataPath,CSIDL_LOCAL_APPDATA,FALSE)) { SHOW_LOG( _T("CExtInstaller::GetChromePreferencePath SHGetSpecialFolderPath failed\n")); return szPreferencePath; } szPreferencePath += lpszAppDataPath; if(bIsSecFile) szPreferencePath += CHROME_SEC_PREFERENCE_PATH; else szPreferencePath += CHROME_PREFERENCE_PATH; SHOW_LOG( _T("CExtInstaller::GetChromePreferencePath szPreferencePath%s\n"), szPreferencePath.c_str()); return szPreferencePath;
void lvc_pack(lvc_t *lvc, int len, char *val) { EXIT_IF_TRUE((lvc->pack_ptr + len) > lvc->len, "lvc buffer is overflown\n"); SHOW_LOG(1, "len:%d\n", len); memcpy((lvc->data + lvc->pack_ptr), &len, sizeof(int)); lvc->pack_ptr += sizeof(int); memcpy(lvc->data + lvc->pack_ptr, val, len); lvc->pack_ptr += len; }
tstring CExtInstaller::GetChromeExtPath(tstring extID, tstring extVersion) { tstring szExtensionRootPath = GetChromeExtensionRoot(); szExtensionRootPath.append(_T("\\")); szExtensionRootPath.append(extID); szExtensionRootPath.append(_T("\\")); szExtensionRootPath.append(extVersion); SHOW_LOG( _T("CExtInstaller::GetChromeExtPath [ChromeExtPath]%s\n"), szExtensionRootPath.c_str()); return szExtensionRootPath;
/** * \fn process_event() * \brief Xu ly cac event, trong vi du la in ra cac thong tin cua event * \param agr1: ics_event_t *event */ void process_event(ics_event_t *event) { ICS_EXIT_IF_TRUE(event->event.eventid >= ICS_EVENT_END, "Unknown event id\n"); SHOW_LOG(3, "Event type: %s\n", ICS_EVENT_NAME[event->event.eventid]); switch(event->event.eventid){ case ICS_REG_START: on_reg_start_p(event->reg_start_event.account_id); break; case ICS_REG_STATE: on_reg_state_p(event->reg_state_event.account_id, (event->reg_state_event.is_registration < 1 || event->reg_state_event.code<0 || event->reg_state_event.code >= 300 ? "No" : "Yes"), event->reg_state_event.code, event->reg_state_event.reason); break; case ICS_INCOMING_CALL: on_incoming_call_p(event->incoming_call_event.account_id, event->incoming_call_event.call_id, event->incoming_call_event.st_code, event->incoming_call_event.remote_contact, event->incoming_call_event.local_contact); break; case ICS_CALL_STATE: on_call_state_p(event->call_state_event.call_id, event->call_state_event.state_code, event->call_state_event.state, event->call_state_event.remote_contact); break; case ICS_TRANSFER: on_call_transfer_p(event->transfer_event.call_id, event->transfer_event.st_code, event->transfer_event.st_text, event->transfer_event.remote_contact); break; case ICS_CALL_MEDIA_STATE: on_call_media_state_p(event->call_media_state_event.call_id, event->call_media_state_event.st_code, event->call_media_state_event.remote_contact); break; default: SHOW_LOG(3, "Invalid event id %d\n", event->event.eventid); break; } }
int lvc_unpack(lvc_t *lvc, int *len, char **val) { int *temp; if (lvc->unpack_ptr >= lvc->len) return -1; temp = (int *)(lvc->data + lvc->unpack_ptr); *len = *temp; SHOW_LOG(1, "lllllen:%d\n", *len); lvc->unpack_ptr += sizeof(int); *val = lvc->data + lvc->unpack_ptr; lvc->unpack_ptr += *len; return 0; }
/** * \fn _ics_adjust_audio_volume() * \brief Tuy chinh am luong cho mic va speaker * \param agr1: ics_t *data * agr2: char *device * agr3: level */ static void _ics_adjust_audio_volume(ics_t *data, int device, float level) { PJ_UNUSED_ARG(data); if (device == 0) { pjsua_conf_adjust_rx_level(0, level); } else if (device == 1) { pjsua_conf_adjust_tx_level(0, level); } else SHOW_LOG(3, "Invalid input to adjust device"); }
static void _ics_conference_call(ics_t *data, int call_id) { int i, max; PJ_UNUSED_ARG(data); max = pjsua_call_get_count(); SHOW_LOG(3, "Let's conference call!\n"); pjsua_call_info ci; #if 1 if ( (call_id != current_call) && pjsua_call_is_active(call_id) ) { pjsua_call_reinvite(call_id, PJ_TRUE, NULL); for (i = 0; i < max; i++) { if (pjsua_call_has_media(i) != 0) { pjsua_conf_connect(pjsua_call_get_conf_port(call_id), pjsua_call_get_conf_port(i)); pjsua_conf_connect(pjsua_call_get_conf_port(i), pjsua_call_get_conf_port(call_id)); } } } else SHOW_LOG(3, "Cannot transfer call!\n"); #endif //For test only: #if 1 for (i = 0; i < max; i++){ if (pjsua_call_is_active(i) && (i != current_call)) { pjsua_call_reinvite(i, PJ_TRUE, NULL); pjsua_call_get_info(i, &ci); pjsua_conf_connect(pjsua_call_get_conf_port(ci.id), pjsua_call_get_conf_port(current_call)); pjsua_conf_connect(pjsua_call_get_conf_port(current_call), pjsua_call_get_conf_port(ci.id)); } break; } #endif }
/* void on_request_adv_server(adv_server_t *adv_server, adv_request_t *request) { //TODO SHOW_LOG(4, fprintf(stdout,"Received: ID = %s\nSDP addr %s:%d\n", request->adv_info.info_id, request->adv_info.sdp_mip, request->adv_info.sdp_port)); } */ void on_request_gmc_server(gmc_server_t *gmc_server, gmc_request_t *request) { node_t *node = gmc_server->user_data; SHOW_LOG(5, fprintf(stdout, "Receive something\n")); switch(request->msg_id) { case GMC_GROUP: SHOW_LOG(4, fprintf(stdout, "Received request:\nAction: %d - Adv_ip: %s\n", request->gmc_group.join, request->gmc_group.adv_ip)); if (request->gmc_group.join == 1) { SHOW_LOG(4, fprintf(stdout, "Join %s\n", request->gmc_group.adv_ip)); adv_server_join(&node->adv_server, request->gmc_group.adv_ip); } else if (request->gmc_group.join == 0) { SHOW_LOG(4, fprintf(stdout, "Leave %s\n", request->gmc_group.adv_ip)); adv_server_leave(&node->adv_server, request->gmc_group.adv_ip); } else { EXIT_IF_TRUE(1, "Unknow action\n"); } break; default: EXIT_IF_TRUE(1, "Unknow request\n"); } }