int CMraProto::SendMsg(MCONTACT hContact, int, const char *lpszMessage) { if (!m_bLoggedIn) { ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)"You cannot send when you are offline."); return 0; } DWORD dwFlags = 0; CMStringW wszMessage(ptrW(mir_utf8decodeT(lpszMessage))); if (wszMessage.IsEmpty()) { ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)"Cant allocate buffer for convert to unicode."); return 0; } CMStringA szEmail; if (!mraGetStringA(hContact, "e-mail", szEmail)) return 0; BOOL bSlowSend = getByte("SlowSend", MRA_DEFAULT_SLOW_SEND); if (getByte("RTFSendEnable", MRA_DEFAULT_RTF_SEND_ENABLE) && (MraContactCapabilitiesGet(hContact) & FEATURE_FLAG_RTF_MESSAGE)) dwFlags |= MESSAGE_FLAG_RTF; int iRet = MraMessage(bSlowSend, hContact, ACKTYPE_MESSAGE, dwFlags, szEmail, wszMessage, NULL, 0); if (bSlowSend == FALSE) ProtoBroadcastAckAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)iRet, 0); return iRet; }
EXPORT_C void CXEDomEx::ParseExampleL() { RXmlEngDocument document; TBuf<KFilePathSize> filepath(iDrive); _LIT(KFilename,"\\xedomexample\\input\\XML_parsing_001.xml"); filepath.Append(KFilename); TFileName srcFileName(filepath); // The API for parsing a file, returns a handle to document document = iDomParser.ParseFileL(srcFileName); if(document.NotNull()) { // We have got the parsed dom tree,it can be used to access tree contents // using document APIs. TPtrC8 name = document.DocumentElement().Name(); // finally closed by calling Close() document.Close(); } // Parse a buffer _LIT8(docW, "<doc>xmlns=\"http://test.pl\"><test>Test Content</test></doc>" ); RXmlEngDocument document2; TPtrC8 ptrW(docW); // The API for parsing a buffer, returns a handle to document document2 = iDomParser.ParseL(ptrW); if(document2.NotNull()) { // Use the document tree and close it finally document2.Close(); } }
int GetValueW(MCONTACT hContact, const char *module, const char *setting, WCHAR *value, int length) { DBVARIANT dbv = { 0 }; if (!module || !setting || !value) return 0; if (length >= 10 && !db_get_s(hContact, module, setting, &dbv, 0)) { switch (dbv.type) { case DBVT_ASCIIZ: mir_wstrncpy(value, ptrW(mir_a2u(dbv.pszVal)), length); break; case DBVT_DWORD: case DBVT_WORD: case DBVT_BYTE: _ultow(getNumericValue(&dbv), value, 10); break; case DBVT_WCHAR: mir_wstrncpy(value, dbv.pwszVal, length); break; case DBVT_UTF8: mir_wstrncpy(value, ptrW(mir_utf8decodeW(dbv.pszVal)), length); break; case DBVT_DELETED: value[0] = 0; return 0; } int type = dbv.type; db_free(&dbv); return type; } value[0] = 0; return 0; }
INT_PTR CALLBACK CSkypeProto::SkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case 0: switch (((LPNMHDR)lParam)->code) { case PSN_PARAMCHANGED: SetWindowLongPtr(hwndDlg, GWLP_USERDATA, ((PSHNOTIFY *)lParam )->lParam); break; case PSN_INFOCHANGED: { CSkypeProto *ppro = (CSkypeProto *)::GetWindowLongPtr(hwndDlg, GWLP_USERDATA); if (!ppro) break; char *szProto; HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lParam)->lParam; if (hContact == NULL) szProto = ppro->m_szModuleName; else szProto = (char *)::CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); if (!szProto) break; ::SetDlgItemText(hwndDlg, IDC_SID, ptrW(::db_get_wsa(hContact, ppro->m_szModuleName, SKYPE_SETTINGS_SID))); DBVARIANT dbv; if ( !::db_get_ts(hContact, ppro->m_szModuleName, "XStatusMsg", &dbv)) { ::SetDlgItemText(hwndDlg, IDC_STATUSTEXT, dbv.ptszVal); ::EnableWindow(::GetDlgItem(hwndDlg, IDC_STATUSTEXT), TRUE); ::db_free(&dbv); } else { ::SetDlgItemText(hwndDlg, IDC_STATUSTEXT, TranslateT("<not specified>")); ::EnableWindow(::GetDlgItem(hwndDlg, IDC_STATUSTEXT), FALSE); } if (::db_get_dw(hContact, ppro->m_szModuleName, "OnlineSinceTS", 0)) { TCHAR date[64]; DBTIMETOSTRINGT tts = {0}; tts.szFormat = _T("d s"); tts.szDest = date; tts.cbDest = sizeof(date); CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, (WPARAM)::db_get_dw(hContact, ppro->m_szModuleName, "OnlineSinceTS", 0), (LPARAM)&tts); ::SetDlgItemText(hwndDlg, IDC_ONLINESINCE, date); ::EnableWindow(::GetDlgItem(hwndDlg, IDC_ONLINESINCE), TRUE); } else { ::SetDlgItemText(hwndDlg, IDC_ONLINESINCE, TranslateT("<not specified>")); ::EnableWindow(::GetDlgItem(hwndDlg, IDC_ONLINESINCE), FALSE); } if (::db_get_dw(hContact, ppro->m_szModuleName, "LastEventDateTS", 0)) { TCHAR date[64]; DBTIMETOSTRINGT tts = {0}; tts.szFormat = _T("d s"); tts.szDest = date; tts.cbDest = sizeof(date); ::CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, (WPARAM)::db_get_dw(hContact, ppro->m_szModuleName, "LastEventDateTS", 0), (LPARAM)&tts); ::SetDlgItemText(hwndDlg, IDC_LASTEVENTDATE, date); ::EnableWindow(::GetDlgItem(hwndDlg, IDC_LASTEVENTDATE), TRUE); } else { ::SetDlgItemText(hwndDlg, IDC_LASTEVENTDATE, TranslateT("<not specified>")); ::EnableWindow(::GetDlgItem(hwndDlg, IDC_LASTEVENTDATE), FALSE); } if (::db_get_dw(hContact, ppro->m_szModuleName, "ProfileTS", 0)) { TCHAR date[64]; DBTIMETOSTRINGT tts = {0}; tts.szFormat = _T("d s"); tts.szDest = date; tts.cbDest = sizeof(date); ::CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, (WPARAM)::db_get_dw(hContact, ppro->m_szModuleName, "ProfileTS", 0), (LPARAM)&tts); ::SetDlgItemText(hwndDlg, IDC_LASTPROFILECHANGE, date); ::EnableWindow(::GetDlgItem(hwndDlg, IDC_LASTPROFILECHANGE), TRUE); } else { ::SetDlgItemText(hwndDlg, IDC_LASTPROFILECHANGE, TranslateT("<not specified>")); ::EnableWindow(::GetDlgItem(hwndDlg, IDC_LASTPROFILECHANGE), FALSE); } } break; } break; } break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDCANCEL: SendMessage(GetParent(hwndDlg), msg, wParam, lParam); break; } break; } return FALSE; }
void IEView::write(const char *text) { write(ptrW(mir_utf8decodeW(text))); }
void CDropbox::RequestAccountInfo() { HttpRequest *request = new HttpRequest(hNetlibUser, REQUEST_GET, DROPBOX_API_URL "/account/info"); request->AddBearerAuthHeader(db_get_sa(NULL, MODULE, "TokenSecret")); mir_ptr<NETLIBHTTPREQUEST> response(request->Send()); delete request; MCONTACT hContact = CDropbox::GetDefaultContact(); if (response && response->resultCode == HTTP_STATUS_OK) { JSONROOT root(response->pData); if (root) { JSONNODE *node = json_get(root, "referral_link"); if (node) { ptrW referral_link = ptrW(json_as_string(node)); db_set_ws(hContact, MODULE, "Homepage", referral_link); } node = json_get(root, "display_name"); if (node) { ptrW display_name = ptrW(json_as_string(node)); wchar_t *sep = wcsrchr(display_name, L' '); if (sep) { db_set_ws(hContact, MODULE, "LastName", sep + 1); display_name[wcslen(display_name) - wcslen(sep)] = '\0'; db_set_ws(hContact, MODULE, "FirstName", display_name); } else { db_set_ws(hContact, MODULE, "FirstName", display_name); db_unset(hContact, MODULE, "LastName"); } } node = json_get(root, "country"); if (node) { ptrW isocodeW(json_as_string(node)); ptrA isocode(mir_u2a(isocodeW)); if (!strlen(isocode)) db_unset(hContact, MODULE, "Country"); else { char *country = (char *)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode, 0); db_set_s(hContact, MODULE, "Country", country); } } node = json_get(root, "quota_info"); JSONNODE *nroot = json_as_node(node); if (nroot) { node = json_get(nroot, "shared"); if (node) db_set_dw(hContact, MODULE, "SharedQuota", json_as_int(node)); node = json_get(nroot, "normal"); if (node) db_set_dw(hContact, MODULE, "NormalQuota", json_as_int(node)); node = json_get(nroot, "quota"); if (node) db_set_dw(hContact, MODULE, "TotalQuota", json_as_int(node)); } } } HandleHttpResponseError(hNetlibUser, response); }
bool CToxProto::InitToxCore() { debugLogA(__FUNCTION__": initializing tox core"); TOX_ERR_OPTIONS_NEW error; Tox_Options *options = tox_options_new(&error); if (error != TOX_ERR_OPTIONS_NEW_OK) { debugLogA(__FUNCTION__": failed to initialize tox options (%d)", error); return false; } options->udp_enabled = getBool("EnableUDP", 1); options->ipv6_enabled = getBool("EnableIPv6", 0); if (hNetlib != NULL) { NETLIBUSERSETTINGS nlus = { sizeof(NETLIBUSERSETTINGS) }; CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM)hNetlib, (LPARAM)&nlus); if (nlus.useProxy) { if (nlus.proxyType == PROXYTYPE_HTTP || nlus.proxyType == PROXYTYPE_HTTPS) { debugLogA("CToxProto::InitToxCore: setting http user proxy config"); options->proxy_type = TOX_PROXY_TYPE_HTTP; mir_strcpy((char*)&options->proxy_host[0], nlus.szProxyServer); options->proxy_port = nlus.wProxyPort; } if (nlus.proxyType == PROXYTYPE_SOCKS4 || nlus.proxyType == PROXYTYPE_SOCKS5) { debugLogA("CToxProto::InitToxCore: setting socks user proxy config"); options->proxy_type = TOX_PROXY_TYPE_SOCKS5; mir_strcpy((char*)&options->proxy_host[0], nlus.szProxyServer); options->proxy_port = nlus.wProxyPort; } } } debugLogA(__FUNCTION__": loading tox profile"); if (LoadToxProfile(options)) { tox_callback_friend_request(tox, OnFriendRequest, this); tox_callback_friend_message(tox, OnFriendMessage, this); tox_callback_friend_read_receipt(tox, OnReadReceipt, this); tox_callback_friend_typing(tox, OnTypingChanged, this); // tox_callback_friend_name(tox, OnFriendNameChange, this); tox_callback_friend_status_message(tox, OnStatusMessageChanged, this); tox_callback_friend_status(tox, OnUserStatusChanged, this); tox_callback_friend_connection_status(tox, OnConnectionStatusChanged, this); // transfers tox_callback_file_recv_control(tox, OnFileRequest, this); tox_callback_file_recv(tox, OnFriendFile, this); tox_callback_file_recv_chunk(tox, OnDataReceiving, this); tox_callback_file_chunk_request(tox, OnFileSendData, this); // group chats //tox_callback_group_invite(tox, OnGroupChatInvite, this); // a/v /*toxAv = toxav_new(tox, TOX_MAX_CALLS); toxav_register_audio_callback(toxAv, OnFriendAudio, this); toxav_register_callstate_callback(toxAv, OnAvInvite, av_OnInvite, this); toxav_register_callstate_callback(toxAv, OnAvStart, av_OnStart, this); toxav_register_callstate_callback(toxAv, OnAvCancel, av_OnCancel, this); toxav_register_callstate_callback(toxAv, OnAvReject, av_OnReject, this); toxav_register_callstate_callback(toxAv, OnAvEnd, av_OnEnd, this); toxav_register_callstate_callback(toxAv, OnAvCallTimeout, av_OnRequestTimeout, this); toxav_register_callstate_callback(toxAv, OnAvPeerTimeout, av_OnPeerTimeout, this);*/ uint8_t data[TOX_ADDRESS_SIZE]; tox_self_get_address(tox, data); ToxHexAddress address(data); setString(TOX_SETTINGS_ID, address); uint8_t nick[TOX_MAX_NAME_LENGTH] = { 0 }; tox_self_get_name(tox, nick); setWString("Nick", ptrW(Utf8DecodeW((char*)nick))); uint8_t statusMessage[TOX_MAX_STATUS_MESSAGE_LENGTH] = { 0 }; tox_self_get_status_message(tox, statusMessage); setWString("StatusMsg", ptrW(Utf8DecodeW((char*)statusMessage))); return true; } tox_options_free(options); return false; }
int CMraProto::MraDbSettingChanged(WPARAM hContact, LPARAM lParam) { if (!m_bLoggedIn || !lParam || !hContact) return 0; DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; // это наш контакт, он не временный (есть в списке на сервере) и его обновление разрешено if (IsContactMra(hContact) && !db_get_b(hContact, "CList", "NotOnList", 0) && getDword(hContact, "HooksLocked", FALSE) == FALSE) { if (!strcmp(cws->szModule, "CList")) { // MyHandle setting if (!strcmp(cws->szSetting, "MyHandle")) { // always store custom nick CMStringW wszNick; if (cws->value.type == DBVT_DELETED) { wszNick = GetContactNameW(hContact); db_set_ws(hContact, "CList", "MyHandle", wszNick); } else if (cws->value.pszVal) { switch (cws->value.type) { case DBVT_WCHAR: wszNick = cws->value.pwszVal; break; case DBVT_UTF8: wszNick = ptrW(mir_utf8decodeW(cws->value.pszVal)); break; case DBVT_ASCIIZ: wszNick = ptrW(mir_a2u_cp(cws->value.pszVal, MRA_CODE_PAGE)); break; } if (wszNick.GetLength()) MraModifyContact(hContact, 0, 0, 0, 0, &wszNick); } } // Group setting else if (!strcmp(cws->szSetting, "Group")) { CMStringW wszGroup; // manage group on server switch (cws->value.type) { case DBVT_WCHAR: wszGroup = cws->value.pwszVal; break; case DBVT_UTF8: wszGroup = ptrW(mir_utf8decodeW(cws->value.pszVal)); break; case DBVT_ASCIIZ: wszGroup = ptrW(mir_a2u_cp(cws->value.pszVal, MRA_CODE_PAGE)); break; } if (wszGroup.GetLength()) { DWORD dwGroupID = getDword(hContact, "GroupID", -1); if (dwGroupID != -1) MraMoveContactToGroup(hContact, dwGroupID, wszGroup); } } // NotOnList setting. Has a temporary contact just been added permanently? else if (!strcmp(cws->szSetting, "NotOnList")) { if (cws->value.type == DBVT_DELETED || (cws->value.type == DBVT_BYTE && cws->value.bVal == 0)) { CMStringW wszAuthMessage; if (!mraGetStringW(NULL, "AuthMessage", wszAuthMessage)) wszAuthMessage = TranslateT(MRA_DEFAULT_AUTH_MESSAGE); db_unset(hContact, "CList", "Hidden"); CMStringA szEmail, szPhones; CMStringW wszNick; DWORD dwGroupID, dwContactFlag; GetContactBasicInfoW(hContact, NULL, &dwGroupID, &dwContactFlag, NULL, NULL, &szEmail, &wszNick, &szPhones); MraAddContact(hContact, dwContactFlag, dwGroupID, szEmail, wszNick, &szPhones, &wszAuthMessage); } } // Hidden setting else if (!strcmp(cws->szSetting, "Hidden")) { DWORD dwContactFlag = GetContactFlags(hContact); if (cws->value.type == DBVT_DELETED || (cws->value.type == DBVT_BYTE && cws->value.bVal == 0)) dwContactFlag &= ~CONTACT_FLAG_SHADOW; else dwContactFlag |= CONTACT_FLAG_SHADOW; MraModifyContact(hContact, 0, &dwContactFlag); } } // Ignore section else if (!strcmp(cws->szModule, "Ignore")) { if (!strcmp(cws->szSetting, "Mask1")) { DWORD dwContactFlag = GetContactFlags(hContact); if (cws->value.type == DBVT_DELETED || (cws->value.type == DBVT_DWORD && cws->value.dVal&IGNOREEVENT_MESSAGE) == 0) dwContactFlag &= ~CONTACT_FLAG_IGNORE; else dwContactFlag |= CONTACT_FLAG_IGNORE; MraModifyContact(hContact, 0, &dwContactFlag); } } // User info section else if (!strcmp(cws->szModule, "UserInfo")) { if (!strcmp(cws->szSetting, "MyPhone0") || !strcmp(cws->szSetting, "MyPhone1") || !strcmp(cws->szSetting, "MyPhone2")) MraModifyContact(hContact); } } return 0; }