static void FetchField(HWND hwndDlg, UINT idCtrl, char *fieldName, char **str, int *strSize) { char text[512]; char *localFieldName, *localText; if (hwndDlg == NULL || fieldName == NULL || str == NULL || strSize == NULL) return; GetDlgItemTextA(hwndDlg, idCtrl, text, _countof(text)); if (text[0]) { if ((localFieldName=TlenTextEncode(fieldName)) != NULL) { if ((localText=TlenTextEncode(text)) != NULL) { TlenStringAppend(str, strSize, "<%s>%s</%s>", localFieldName, localText, localFieldName); mir_free(localText); } mir_free(localFieldName); } } }
static void FetchCombo(HWND hwndDlg, UINT idCtrl, char *fieldName, char **str, int *strSize) { if (hwndDlg == NULL || fieldName == NULL || str == NULL || strSize == NULL) return; int value = (int) SendDlgItemMessage(hwndDlg, idCtrl, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, idCtrl, CB_GETCURSEL, 0, 0), 0); if (value > 0) { if (char *localFieldName = TlenTextEncode(fieldName)) { TlenStringAppend(str, strSize, "<%s>%d</%s>", localFieldName, value, localFieldName); mir_free(localFieldName); } } }
static int TlenMUCSendPresence(TlenProtocol *proto, const char *roomID, const char *nick, int desiredStatus) { char str[512]; char *jid; TLEN_LIST_ITEM *item; if (!proto->isOnline) { return 1; } if (nick != NULL) { mir_snprintf(str, SIZEOF(str), "%s/%s", roomID, nick); } else { strncpy_s(str, roomID, _TRUNCATE); } if ((jid = TlenTextEncode(str)) != NULL) { switch (desiredStatus) { case ID_STATUS_ONLINE: TlenSend(proto, "<p to='%s'/>", jid); item = TlenListGetItemPtr(proto, LIST_CHATROOM, roomID); if (item != NULL) { if (item->nick != NULL) mir_free(item->nick); item->nick = NULL; if (nick != NULL) { item->nick = mir_strdup(nick); } } break; default: item = TlenListGetItemPtr(proto, LIST_CHATROOM, roomID); if (item != NULL) { TlenSend(proto, "<p to='%s'><s>unavailable</s></p>", jid); TlenListRemove(proto, LIST_CHATROOM, roomID); } break; } mir_free(jid); } return 0; }