MCONTACT CSkypeProto::AddContact(const char *skypename, bool isTemporary) { MCONTACT hContact = FindContact(skypename); if (!hContact) { hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); Proto_AddToContact(hContact, m_szModuleName); setString(hContact, SKYPE_SETTINGS_ID, skypename); DBVARIANT dbv; if (!getTString(SKYPE_SETTINGS_GROUP, &dbv)) { db_set_ts(hContact, "CList", "Group", dbv.ptszVal); db_free(&dbv); } setByte(hContact, "Auth", 1); setByte(hContact, "Grant", 1); if (isTemporary) db_set_b(hContact, "CList", "NotOnList", 1); } return hContact; }
bool AD5933_Class::setStepSizeInHex(long freqHex) { if (freqHex > 0xFFFFFF) { #if LOGGING1 printer->print("setIncrementHex - Freqeuncy Overflow!"); #endif return false; } int lowerHex = freqHex % 256; int midHex = ((freqHex - (long)lowerHex) >> 8) % 256; int upperHex = freqHex >> 16; bool t2, t3, t4; t2 = setByte(0x85, upperHex); t3 = setByte(0x86, midHex); t4 = setByte(0x87, lowerHex); if (t2 && t3 && t4) { incrHex = freqHex; return true; // Succeed! } else { #if LOGGING1 printer->println("setIncrementHex - Data Transmission Failed!"); #endif return false; } }
bool AD5933_Class::setIncrementinHex(long freqHex) // Function to set increment frequency in converted Hex value. (calculated based on the datasheet.) // long freqHex - converted hexadecimal value { if (freqHex > 0xFFFFFF) { #if LOGGING1 printer->print("setIncrementHex - Freqeuncy Overflow!"); #endif return false; } int lowerHex = freqHex % 256; int midHex = ((freqHex - (long)lowerHex) >> 8) % 256; int upperHex = freqHex >> 16; bool t2, t3, t4; t2 = setByte(0x85, upperHex); t3 = setByte(0x86, midHex); t4 = setByte(0x87, lowerHex); if (t2 && t3 && t4) { incrHex = freqHex; return true; // Succeed! } else { #if LOGGING1 printer->println("setIncrementHex - Data Transmission Failed!"); #endif return false; } }
bool AD5933_Class::setNumofIncrement(byte num) // Function to set the number of incrementing. // byte num - the number of incrementing. { if (num > 0x1FF + 1) { #if LOGGING1 printer->print("setNumofIncrement - Frequency Overflow!"); #endif return false; } int lowerHex = num % 256; int upperHex = (num >> 8) % 2; // Parsing number for register input. bool t2, t4; t2 = setByte(0x88, upperHex); t4 = setByte(0x89, lowerHex); if (t2 && t4) { numIncrement = num + 1; return true; // Succeed! } else { #if LOGGING1 printer->println("setNumofIncrement - Data Transmission Failed!"); #endif return false; } }
INT_PTR GGPROTO::setmyavatar(WPARAM wParam, LPARAM lParam) { TCHAR *szFilename = (TCHAR*)lParam; if (!getByte(GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS)) return -2; if (szFilename == NULL) { MessageBox(NULL, TranslateT("To remove your Gadu-Gadu avatar, you must use the gg.pl website."), m_tszUserName, MB_OK | MB_ICONINFORMATION); return -1; } int iAvType = ProtoGetAvatarFormat(szFilename); if ( iAvType == PA_FORMAT_UNKNOWN) { debugLogA("setmyavatar(): Failed to set user avatar. File %s has incompatible extension.", szFilename); return -1; } setByte(GG_KEY_AVATARTYPEPREV, getByte(GG_KEY_AVATARTYPE, -1)); setByte(GG_KEY_AVATARTYPE, (BYTE)iAvType); TCHAR szMyFilename[MAX_PATH]; getAvatarFilename(NULL, szMyFilename, _countof(szMyFilename)); if ( mir_tstrcmp(szFilename, szMyFilename) && !CopyFile(szFilename, szMyFilename, FALSE)) { debugLogA("setmyavatar(): Failed to set user avatar. File with type %d could not be created/overwritten.", iAvType); return -1; } setAvatar(szMyFilename); return 0; }
INT_PTR CALLBACK CSOptionsProc(HWND hwnd, UINT message, WPARAM, LPARAM lparam) { switch (message) { case WM_INITDIALOG: TranslateDialogDefault(hwnd); CheckDlgButton(hwnd, IDC_CONFIRM_DELETION, getByte("ConfirmDeletion", DEFAULT_PLUGIN_CONFIRM_ITEMS_DELETION) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwnd, IDC_DELETE_AFTER_IMPORT, getByte("DeleteAfterImport", DEFAULT_PLUGIN_DELETE_AFTER_IMPORT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwnd, IDC_REMEMBER_POSITION, getByte("RememberWindowPosition", DEFAULT_REMEMBER_WINDOW_POSITION) ? BST_CHECKED : BST_UNCHECKED); return TRUE; case WM_NOTIFY: switch (((LPNMHDR)lparam)->code) { case PSN_APPLY: setByte("ConfirmDeletion", IsDlgButtonChecked(hwnd, IDC_CONFIRM_DELETION) ? 1 : 0); setByte("DeleteAfterImport", IsDlgButtonChecked(hwnd, IDC_DELETE_AFTER_IMPORT) ? 1 : 0); setByte("RememberWindowPosition", IsDlgButtonChecked(hwnd, IDC_REMEMBER_POSITION) ? 1 : 0); Menu_ReloadProtoMenus(); break; } return TRUE; } return FALSE; }
void CSItemsList::saveItems(char *protoName) { unsigned int i; char dbSetting[32]; mir_snprintf(dbSetting, "%s_ItemsCount", protoName); unsigned int oldItemsCount = getWord(dbSetting, DEFAULT_ITEMS_COUNT); for (i = 1; i <= m_list->getCount(); i++) { StatusItem* item = m_list->get(i - 1); mir_snprintf(dbSetting, "%s_Item%dIcon", protoName, i); setByte(dbSetting, item->m_iIcon); mir_snprintf(dbSetting, "%s_Item%dTitle", protoName, i); setWString(dbSetting, item->m_tszTitle); mir_snprintf(dbSetting, "%s_Item%dMessage", protoName, i); setWString(dbSetting, item->m_tszMessage); mir_snprintf(dbSetting, "%s_Item%dFavourite", protoName, i); setByte(dbSetting, item->m_bFavourite); } mir_snprintf(dbSetting, "%s_ItemsCount", protoName); setWord(dbSetting, m_list->getCount()); for (; i <= oldItemsCount; i++) { mir_snprintf(dbSetting, "%s_Item%dIcon", protoName, i); deleteSetting(dbSetting); mir_snprintf(dbSetting, "%s_Item%dTitle", protoName, i); deleteSetting(dbSetting); mir_snprintf(dbSetting, "%s_Item%dMessage", protoName, i); deleteSetting(dbSetting); mir_snprintf(dbSetting, "%s_Item%dFavourite", protoName, i); deleteSetting(dbSetting); } }
void setShort(byte* array, int& position, unsigned short value, int length) { byte* bvalue = (byte*) &value; if(length > 8) { byte filled = length - 8; setByte(array, position, bvalue[1], filled); length = 8; } setByte(array, position, bvalue[0], length); }
void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) { debugLogA("CVkProto::OnReceiveUserInfo %d", reply->resultCode); if (reply->resultCode != 200) return; JSONROOT pRoot; JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot); if (pResponse == NULL) return; for (size_t i=0; ; i++) { JSONNODE *pRecord = json_at(pResponse, i); if (pRecord == NULL) break; LONG userid = json_as_int( json_get(pRecord, "uid")); if (userid == 0) return; MCONTACT hContact; if (userid == m_myUserId) hContact = NULL; else if ((hContact = FindUser(userid, false)) == NULL) return; CMString tszNick; ptrT szValue( json_as_string( json_get(pRecord, "first_name"))); if (szValue) { setTString(hContact, "FirstName", szValue); tszNick.Append(szValue); tszNick.AppendChar(' '); } if (szValue = json_as_string( json_get(pRecord, "last_name"))) { setTString(hContact, "LastName", szValue); tszNick.Append(szValue); } if (!tszNick.IsEmpty()) setTString(hContact, "Nick", tszNick); setByte(hContact, "Gender", json_as_int( json_get(pRecord, "sex")) == 2 ? 'M' : 'F'); if (szValue = json_as_string( json_get(pRecord, "bdate"))) { int d, m, y; if ( _stscanf(szValue, _T("%d.%d.%d"), &d, &m, &y) == 3) { setByte(hContact, "BirthDay", d); setByte(hContact, "BirthMonth", m); setWord(hContact, "BirthYear", y); } } szValue = json_as_string( json_get(pRecord, "photo_medium")); SetAvatarUrl(hContact, szValue); } }
bool AD5933_Class::setSettlingCycles(int cycles, byte mult) { if (cycles > 0x1FF || !(mult == 1 || mult == 2 || mult == 4) ) { #if LOGGING1 printer->println("setSettlingCycles - Invalid Parameter"); #endif return false; } int lowerHex = cycles % 256; int upperHex = ((cycles - (long)lowerHex) >> 8) % 2; byte t1; // Parsing upper and lower bits. /*switch(mult) { case 1: t1 = 0; break; case 2: t1 = 1; break; case 4: t1 = 3; break; default: #if LOGGING1 printer->println("setSettlingCycles - Invalid Mult Parameter"); #endif return false; break; }*/ t1--; // Enhanced Code for setting t1. upperHex |= (t1 << 1); // t1 is for D9, D10. The upperHex just accounts for D8. Thus, the value after left-shifting t1 accounts for D9, D10. // Thus, this above writes bits for D9, D10. #if LOGGING2 printer->print("setSettlingCycles - upper: "); printer->println(upperHex, BIN); #endif bool t2, t3; t2 = setByte(0x8A, upperHex); t3 = setByte(0x8B, lowerHex); if ( t2 && t3 ) // Checking if successful. return true; // Succeed! else { #if LOGGING1 printer->println("setSettingCycles - Data Write Fail"); #endif return false; } }
void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) { debugLogA("CVkProto::OnReceiveFriends %d", reply->resultCode); if (reply->resultCode != 200 || !IsOnline()) return; JSONNode jnRoot; const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot); if (!jnResponse) return; CVkSendMsgParam *param = (CVkSendMsgParam *)pReq->pUserInfo; bool bCleanContacts = getBool("AutoClean") || (param->iMsgID != 0); delete param; LIST<void> arContacts(10, PtrKeySortT); for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { if (!isChatRoom(hContact)) setByte(hContact, "Auth", 1); db_unset(hContact, m_szModuleName, "ReqAuth"); SetMirVer(hContact, -1); if (bCleanContacts && !isChatRoom(hContact)) arContacts.insert((HANDLE)hContact); } const JSONNode &jnItems = jnResponse["items"]; if (jnItems) for (auto it = jnItems.begin(); it != jnItems.end(); ++it) { MCONTACT hContact = SetContactInfo((*it), true); if (hContact == NULL || hContact == INVALID_CONTACT_ID) continue; arContacts.remove((HANDLE)hContact); setByte(hContact, "Auth", 0); } if (bCleanContacts) for (int i = 0; i < arContacts.getCount(); i++) { MCONTACT hContact = (UINT_PTR)arContacts[i]; LONG userID = getDword(hContact, "ID", -1); if (userID == m_myUserId || userID == VK_FEED_USER) continue; CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact); } arContacts.destroy(); }
void CJabberProto::UpdateSubscriptionInfo(MCONTACT hContact, JABBER_LIST_ITEM *item) { switch (item->subscription) { case SUB_TO: setTString(hContact, "SubscriptionText", TranslateT("To")); setString(hContact, "Subscription", "to"); setByte(hContact, "Auth", 0); setByte(hContact, "Grant", 1); break; case SUB_FROM: setTString(hContact, "SubscriptionText", TranslateT("From")); setString(hContact, "Subscription", "from"); setByte(hContact, "Auth", 1); setByte(hContact, "Grant", 0); break; case SUB_BOTH: setTString(hContact, "SubscriptionText", TranslateT("Both")); setString(hContact, "Subscription", "both"); setByte(hContact, "Auth", 0); setByte(hContact, "Grant", 0); break; case SUB_NONE: setTString(hContact, "SubscriptionText", TranslateT("None")); setString(hContact, "Subscription", "none"); setByte(hContact, "Auth", 1); setByte(hContact, "Grant", 1); break; } }
void TM1638::setChar(const uint8_t pos, const char value) { const uint8_t b = TM1638_map_char(value); if (b) setByte(pos, b); else if (value >= 'a' && value <= 'z') setByte(pos, pgm_read_byte(&TM_DIGITS[value - 'a' + 10])); else if (value >= 'A' && value <= 'Z') setByte(pos, pgm_read_byte(&TM_DIGITS[value - 'A' + 10])); else if (value >= '0' && value <= '9') setByte(pos, pgm_read_byte(&TM_DIGITS[value - '0'])); }
void setByte(byte* array, int& position, byte value, int length) { // nothing to copy if(length == 0) return; // for 0-padded bitstrings stored as bytes if(length > 8) { int extra = length - 8; setByte(array, position, 0, extra); length -= extra; } // get byte and bit offset unsigned int whichByte = position >> 3; byte whichBit = position - (whichByte << 3); // handle the left hand side if it crosses a boundary byte shift, mask; if(whichBit + length > 8) { shift = whichBit + length - 8; byte shifted = value; shifted >>= shift; byte filled = 8 - whichBit; byte mask = ((1 << filled) - 1); array[whichByte] = combine(shifted, array[whichByte], mask); position += filled; length -= filled; whichByte++; whichBit = 0; }
MCONTACT CToxProto::AddChatRoom(int groupNumber) { MCONTACT hContact = GetChatRoom(groupNumber); if (!hContact) { hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); Proto_AddToContact(hContact, m_szModuleName); setWord(hContact, TOX_SETTINGS_CHAT_ID, groupNumber); TCHAR title[MAX_PATH]; mir_sntprintf(title, _T("%s #%d"), TranslateT("Group chat"), groupNumber); setTString(hContact, "Nick", title); DBVARIANT dbv; if (!db_get_s(NULL, "Chat", "AddToGroup", &dbv, DBVT_TCHAR)) { db_set_ts(hContact, "CList", "Group", dbv.ptszVal); db_free(&dbv); } setByte(hContact, "ChatRoom", 1); } return hContact; }
void CAimProto::avatar_request_handler(HANDLE hContact, char* hash, unsigned char type)//checks to see if the avatar needs requested { if (hContact == NULL) { hash = hash_lg ? hash_lg : hash_sm; type = hash_lg ? 12 : 1; } char* saved_hash = getSetting(hContact, AIM_KEY_AH); if (hash && _stricmp(hash, "0201d20472") && _stricmp(hash, "2b00003341")) //gaim default icon fix- we don't want their blank icon displaying. { if (_strcmps(saved_hash, hash)) { setByte(hContact, AIM_KEY_AHT, type); setString(hContact, AIM_KEY_AH, hash); sendBroadcast(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0); } } else { if (saved_hash) { deleteSetting(hContact, AIM_KEY_AHT); deleteSetting(hContact, AIM_KEY_AH); sendBroadcast(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0); } } mir_free(saved_hash); }
UTDigital::UTDigital( void ) { int byte; MMMessage( "Initializing Digital IO components..." ); // Set the MPC550 Digital IO directions // Port A - output, Port B - input // Port C bits 0-3 output // Port C bits 4-7 input */ MPC550Card->setDIODir( true, false, false, true); // Set all the DM6814 digital channels to input DM6814Card[0]->setDIODir( 0, false, false ); DM6814Card[0]->setDIODir( 1, false, false ); DM6814Card[0]->setDIODir( 2, false, false ); DM6814Card[1]->setDIODir( 0, false, false ); DM6814Card[1]->setDIODir( 1, false, false ); DM6814Card[1]->setDIODir( 2, false, false ); // Reset all the digital outputs for ( byte = 0; byte < 9; byte++ ) { setByte( byte, 0x00 ); } MMMessage( "done.\n" ); }
void PsiSection::finalize() { Section::finalize(); Section::setSectionSyntaxIndicator(true); /* reserved 2 (after table_id_extension) */ setByte(5, getByte(5) | 0xC0); /* 1100 0000 */ /* crc 32 */ unsigned sectionLength = getSectionLength(); unsigned crc = calculateCrc(data, sectionLength - 1); setByte(sectionLength - 1, (crc & 0xFF000000) >> 24); setByte(sectionLength , (crc & 0x00FF0000) >> 16); setByte(sectionLength + 1, (crc & 0x0000FF00) >> 8); setByte(sectionLength + 2, (crc & 0x000000FF) ); }
void CVkProto::OnReceiveAvatar(NETLIBHTTPREQUEST *reply, AsyncHttpRequest* pReq) { if (reply->resultCode != 200 || !pReq->pUserInfo) return; PROTO_AVATAR_INFORMATION ai = { 0 }; CVkSendMsgParam * param = (CVkSendMsgParam *)pReq->pUserInfo; GetAvatarFileName(param->hContact, ai.filename, _countof(ai.filename)); ai.format = ProtoGetBufferFormat(reply->pData); FILE *out = _tfopen(ai.filename, _T("wb")); if (out == NULL) { ProtoBroadcastAck(param->hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, &ai); delete param; pReq->pUserInfo = NULL; return; } fwrite(reply->pData, 1, reply->dataLength, out); fclose(out); setByte(param->hContact, "NeedNewAvatar", 0); ProtoBroadcastAck(param->hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, &ai); delete param; pReq->pUserInfo = NULL; }
bool AD5933_Class::setRange(byte rangeToSet, int ctrReg) { ctrReg &= 0xF9; // Clear D9 & D10 to modify switch (rangeToSet) { case RANGE_1: ctrReg |= 0x00; //Serial.println("Changed to RANGE_1"); break; case RANGE_2: ctrReg |= 0x06; //Serial.println("Changed to RANGE_2"); break; case RANGE_3: ctrReg |= 0x04; //Serial.println("Changed to RANGE_3"); break; case RANGE_4: ctrReg |= 0x02; //Serial.println("Changed to RANGE_4"); break; default: #if LOGGING1 printer->println("setRange - Invalid Parameter!"); #endif return false; // return the signal of fail if there is not valid parameter. break; } return setByte(0x80, ctrReg); // return signal depends on the result of setting control register. }
DWORD CMraProto::MraSetXStatusInternal(DWORD dwXStatus) { if (IsXStatusValid(dwXStatus)) { CMStringW szBuff; // obsolete (TODO: remove in next version) char szValueName[MAX_PATH]; mir_snprintf(szValueName, SIZEOF(szValueName), "XStatus%ldName", dwXStatus); if (!mraGetStringW(NULL, szValueName, szBuff)) szBuff = lpcszXStatusNameDef[dwXStatus]; mraSetStringExW(NULL, DBSETTING_XSTATUSNAME, szBuff); // obsolete (TODO: remove in next version) mir_snprintf(szValueName, SIZEOF(szValueName), "XStatus%ldMsg", dwXStatus); if (mraGetStringW(NULL, szValueName, szBuff)) mraSetStringExW(NULL, DBSETTING_XSTATUSMSG, szBuff); else delSetting(DBSETTING_XSTATUSMSG); } else { delSetting(DBSETTING_XSTATUSNAME); delSetting(DBSETTING_XSTATUSMSG); dwXStatus = MRA_MIR_XSTATUS_NONE; } DWORD dwOldStatusMode = InterlockedExchange((volatile LONG*)&m_iXStatus, dwXStatus); setByte(DBSETTING_XSTATUSID, (BYTE)dwXStatus); MraSendNewStatus(m_iStatus, dwXStatus, _T(""), _T("")); return dwOldStatusMode; }
bool AD5933_Class::setPGA(byte pgaGain, int ctrReg) { ctrReg &= 0xFE; // Get D8. switch (pgaGain) { case GAIN_1: ctrReg |= 0x00; Serial.println("Changed to GAIN_1"); break; case GAIN_5: ctrReg |= 0x01; Serial.println("Changed to GAIN_5"); break; default: #if LOGGING1 printer->println("setRange - Invalid Parameter!"); #endif return false; // return the signal of fail if there is not valid parameter. break; } return setByte(0x80, ctrReg); // return signal depends on the result of setting control register. }
int FacebookProto::GetInfo(MCONTACT hContact, int infoType) { ptrA user_id(getStringA(hContact, FACEBOOK_KEY_ID)); if (user_id == NULL) return 1; facebook_user fbu; fbu.user_id = user_id; LoadContactInfo(&fbu); // TODO: don't duplicate code this way, refactor all this userInfo loading // TODO: load more info about user (authorization state,...) std::string homepage = FACEBOOK_URL_PROFILE + fbu.user_id; setString(hContact, "Homepage", homepage.c_str()); if (!fbu.real_name.empty()) { SaveName(hContact, &fbu); } if (fbu.gender) setByte(hContact, "Gender", fbu.gender); CheckAvatarChange(hContact, fbu.image_url); return 1; }
void __cdecl CYahooProto::send_avt_thread(void *psf) { struct yahoo_file_info *sf = (yahoo_file_info*)psf; if (sf == NULL) { debugLogA("[yahoo_send_avt_thread] SF IS NULL!!!"); return; } setByte("AvatarUL", 1); yahoo_send_avatar(m_id, sf->filename, sf->filesize, &upload_avt, sf); free(sf->filename); free(sf); if (getByte("AvatarUL", 1) == 1) setByte("AvatarUL", 0); }
bool AD5933_Class::setStartFreq(long startFreq) // long startFreq in Hz { #if LOGGING3 //double t1 = opClock / pow(2,29); //printer->println(t1); #endif long freqHex = startFreq / (opClock / pow(2, 29)); // based on datasheet if (freqHex > 0xFFFFFF) { #if LOGGING1 printer->print("setStartFreq - Freqeuncy Overflow!"); #endif return false; } int lowerHex = freqHex % 256; int midHex = ((freqHex - (long)lowerHex) >> 8) % 256; int upperHex = freqHex >> 16; #if LOGGING3 printer->print("setStartFreq - freqHex: "); printer->print(freqHex, HEX); printer->print("\t"); printer->print("lower: "); printer->print(lowerHex, HEX); printer->print("\t"); printer->print("mid: "); printer->print(midHex, HEX); printer->print("\t"); printer->print("upper: "); printer->print(upperHex, HEX); printer->println(); #endif bool t2, t3, t4; t2 = setByte(0x82, upperHex); t3 = setByte(0x83, midHex); t4 = setByte(0x84, lowerHex); if (t2 && t3 && t4) return true; // succeed! else { #if LOGGING1 printer->println("setStartFreq - Data Transmission Failed!"); #endif return false; } }
void CSkypeProto::UpdateProfileGender(const JSONNode &root, MCONTACT hContact) { CMString gender = root["gender"].as_mstring(); if (!gender.IsEmpty() && gender != "null") setByte(hContact, "Gender", (BYTE)(_ttoi(gender) == 1 ? 'M' : 'F')); else delSetting(hContact, "Gender"); }
BOOL CIrcProto::CList_AddDCCChat(const CMString& name, const CMString& hostmask, unsigned long adr, int port) { MCONTACT hContact; TCHAR szNick[256]; char szService[256]; bool bFlag = false; CONTACT usertemp = { (TCHAR*)name.c_str(), NULL, NULL, false, false, true }; MCONTACT hc = CList_FindContact(&usertemp); if (hc && db_get_b(hc, "CList", "NotOnList", 0) == 0 && db_get_b(hc, "CList", "Hidden", 0) == 0) bFlag = true; CMString contactname = name; contactname += DCCSTRING; CONTACT user = { (TCHAR*)contactname.c_str(), NULL, NULL, false, false, true }; hContact = CList_AddContact(&user, false, false); setByte(hContact, "DCC", 1); DCCINFO* pdci = new DCCINFO; pdci->sHostmask = hostmask; pdci->hContact = hContact; pdci->dwAdr = (DWORD)adr; pdci->iPort = port; pdci->iType = DCC_CHAT; pdci->bSender = false; pdci->sContactName = name; if (m_DCCChatAccept == 3 || m_DCCChatAccept == 2 && bFlag) { CDccSession* dcc = new CDccSession(this, pdci); CDccSession* olddcc = FindDCCSession(hContact); if (olddcc) olddcc->Disconnect(); AddDCCSession(hContact, dcc); dcc->Connect(); if (getByte("MirVerAutoRequest", 1)) PostIrcMessage(_T("/PRIVMSG %s \001VERSION\001"), name.c_str()); } else { CLISTEVENT cle = { sizeof(cle) }; cle.hContact = hContact; cle.hDbEvent = (HANDLE)"dccchat"; cle.flags = CLEF_TCHAR; cle.hIcon = LoadIconEx(IDI_DCC); mir_snprintf(szService, sizeof(szService), "%s/DblClickEvent", m_szModuleName); cle.pszService = szService; mir_sntprintf(szNick, SIZEOF(szNick), TranslateT("CTCP chat request from %s"), name.c_str()); cle.ptszTooltip = szNick; cle.lParam = (LPARAM)pdci; if (CallService(MS_CLIST_GETEVENT, hContact, 0)) CallService(MS_CLIST_REMOVEEVENT, hContact, (LPARAM)"dccchat"); CallService(MS_CLIST_ADDEVENT, hContact, (LPARAM)&cle); } return TRUE; }
void CSkypeProto::UpdateProfileBirthday(const JSONNode &root, MCONTACT hContact) { CMString birthday = root["birthday"].as_mstring(); if (!birthday.IsEmpty() && birthday != "null") { int d, m, y; _stscanf(birthday.GetBuffer(), _T("%d-%d-%d"), &y, &m, &d); setWord(hContact, "BirthYear", y); setByte(hContact, "BirthDay", d); setByte(hContact, "BirthMonth", m); } else { delSetting(hContact, "BirthYear"); delSetting(hContact, "BirthDay"); delSetting(hContact, "BirthMonth"); } }
void KeyPointFilter::setMap(int sInd, int eInd) { int sb = sInd / 8; int so = sInd % 8; int eb = eInd / 8; int eo = eInd % 8; if (sb == eb) setByte(bitmap + sb, so, eo); else { setByte(bitmap + sb, so, 8); sb++; while (sb < eb) { setByte(bitmap + sb, 0, 8); sb++; } setByte(bitmap + eb, 0, eo); } }
int CompositeChannelBuffer::setShort(int index, int value) { int componentId = getComponentId(index); if (index + 2 <= indices[componentId + 1]) { return components[componentId]->setShort(index - indices[componentId], value); } else if (order() == ByteOrder::BIG) { setByte(index, (value >> 8)); setByte(index + 1, value); }