CChatItem* CChatSelector::StartSession(CUpDownClient* client, bool show) { ::SetFocus(m_hwndMessageBox); if (GetTabByClient(client) != 0xFFFF){ if (show){ SetCurSel(GetTabByClient(client)); ShowChat(); } return NULL; } CChatItem* chatitem = new CChatItem(); chatitem->client = client; chatitem->log = new CHTRichEditCtrl; CRect rcChat; GetChatSize(rcChat); if (GetItemCount() == 0) rcChat.top += 20; chatitem->log->Create(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL | ES_MULTILINE | ES_READONLY, rcChat, this, (UINT)-1); chatitem->log->ModifyStyleEx(0, WS_EX_STATICEDGE, SWP_FRAMECHANGED); chatitem->log->SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(3, 3)); chatitem->log->SetEventMask(chatitem->log->GetEventMask() | ENM_LINK); chatitem->log->SetFont(&theApp.m_fontHyperText); chatitem->log->SetProfileSkinKey(_T("Chat")); chatitem->log->ApplySkin(); CTime theTime = CTime::GetCurrentTime(); CString sessions = GetResString(IDS_CHAT_START) + client->GetUserName() + CString(_T(" - ")) + theTime.Format(_T("%c")) + _T("\n"); chatitem->log->AppendKeyWord(sessions, RGB(255,0,0)); client->SetChatState(MS_CHATTING); CString name; if (client->GetUserName() != NULL) name = client->GetUserName(); else name.Format(_T("(%s)"), GetResString(IDS_UNKNOWN)); chatitem->log->SetTitle(name); TCITEM newitem; newitem.mask = TCIF_PARAM | TCIF_TEXT | TCIF_IMAGE; newitem.lParam = (LPARAM)chatitem; newitem.pszText = const_cast<LPTSTR>((LPCTSTR)name); newitem.iImage = 0; int iItemNr = InsertItem(GetItemCount(), &newitem); if (show || IsWindowVisible()){ SetCurSel(iItemNr); ShowChat(); } return chatitem; }
void CChatSelector::EndSession(CUpDownClient* client) { int iCurSel; if (client) iCurSel = GetTabByClient(client); else iCurSel = GetCurSel(); if (iCurSel == -1) return; TCITEM item; item.mask = TCIF_PARAM; if (!GetItem(iCurSel, &item) || item.lParam == 0) return; CChatItem* ci = (CChatItem*)item.lParam; ci->client->SetChatState(MS_NONE); ci->client->SetChatCaptchaState(CA_NONE); DeleteItem(iCurSel); delete ci; int iTabItems = GetItemCount(); if (iTabItems > 0){ // select next tab if (iCurSel == CB_ERR) iCurSel = 0; else if (iCurSel >= iTabItems) iCurSel = iTabItems - 1; (void)SetCurSel(iCurSel); // returns CB_ERR if error or no prev. selection(!) iCurSel = GetCurSel(); // get the real current selection if (iCurSel == CB_ERR) // if still error iCurSel = SetCurSel(0); ShowChat(); } }
bool C4ChatDlg::ToggleChat() { if (pInstance && pInstance->IsShown()) StopChat(); else ShowChat(); return true; }
void CChatSelector::EndSession(CUpDownClient* client, bool bForceFocus /* true */) { if (!g_App.m_pMDlg->IsRunning()) return; int iCurSel; if (client != NULL) iCurSel = GetTabByClient(client); else iCurSel = GetCurSel(); if (iCurSel == -1) return; TCITEM tcitem; tcitem.mask = TCIF_PARAM; if (!GetItem(iCurSel, &tcitem) || tcitem.lParam == 0) return; CChatItem *pChatItem = (CChatItem*)tcitem.lParam; pChatItem->m_pClient->SetChatState(MS_NONE); DeleteItem(iCurSel); delete pChatItem; int iTabItems = GetItemCount(); if (iTabItems > 0) { // Select next tab if (iCurSel >= iTabItems) iCurSel = iTabItems - 1; SetCurSel(iCurSel); // Returns CB_ERR if error or no prev. selection(!) iCurSel = GetCurSel(); // get the real current selection if (iCurSel == CB_ERR) // if still error iCurSel = SetCurSel(0); if (bForceFocus) ShowChat(); } }
void CChatSelector::OnTcnSelChangeChatSel(NMHDR* /*pNMHDR*/, LRESULT* pResult) { ShowChat(); *pResult = 0; }
CChatItem* CChatSelector::StartSession(CUpDownClient* client, bool show) { if (show) m_pParent->m_wndMessage.SetFocus(); if (GetTabByClient(client) != -1){ if (show){ SetCurSel(GetTabByClient(client)); ShowChat(); } return NULL; } CChatItem* chatitem = new CChatItem(); chatitem->client = client; chatitem->log = new CHTRichEditCtrl; CRect rcChat; GetChatSize(rcChat); if (GetItemCount() == 0) rcChat.top += 19; // add the height of the tab which is not yet there // using ES_NOHIDESEL is actually not needed, but it helps to get around a tricky window update problem! // If that style is not specified there are troubles with right clicking into the control for the very first time!? chatitem->log->Create(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL | ES_MULTILINE | ES_READONLY | ES_NOHIDESEL, rcChat, this, (UINT)-1); chatitem->log->ModifyStyleEx(0, WS_EX_STATICEDGE, SWP_FRAMECHANGED); chatitem->log->SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(3, 3)); chatitem->log->SetEventMask(chatitem->log->GetEventMask() | ENM_LINK); chatitem->log->SetFont(&theApp.m_fontHyperText); chatitem->log->SetProfileSkinKey(_T("Chat")); chatitem->log->ApplySkin(); chatitem->log->EnableSmileys(thePrefs.GetMessageEnableSmileys()); PARAFORMAT pf = {0}; pf.cbSize = sizeof pf; pf.dwMask = PFM_OFFSET; pf.dxOffset = 150; chatitem->log->SetParaFormat(pf); if (thePrefs.GetIRCAddTimeStamp()) AddTimeStamp(chatitem); chatitem->log->AppendKeyWord(GetResString(IDS_CHAT_START) + client->GetUserName() + _T("\n"), STATUS_MSG_COLOR); client->SetChatState(MS_CHATTING); CString name; if (client->GetUserName() != NULL) name = client->GetUserName(); else name.Format(_T("(%s)"), GetResString(IDS_UNKNOWN)); chatitem->log->SetTitle(name); TCITEM newitem; newitem.mask = TCIF_PARAM | TCIF_TEXT | TCIF_IMAGE; newitem.lParam = (LPARAM)chatitem; name.Replace(_T("&"), _T("&&")); newitem.pszText = const_cast<LPTSTR>((LPCTSTR)name); newitem.iImage = 0; int iItemNr = InsertItem(GetItemCount(), &newitem); if (show || IsWindowVisible()){ SetCurSel(iItemNr); ShowChat(); } return chatitem; }
int main(int argc, char* argv[]) { int i = 0; char symbol; int end_app = 0; int task = 0; int server = msgget(15071410, 0644 | O_EXCL); struct msgbuf message; struct msgbuf m[20]; for(i=0; i<20; i++) { strcpy(m[i].text, ""); strcpy(m[i].nick, ""); strcpy(m[i].date, ""); } if (server == -1) { printf("Blad komunikacji z serwerem! \n"); } InitMenu(); while(!end_app) { printf("\nPodaj ID zadania: "); scanf("%d",&task); switch(task) { case 1: printf("Logowanie. Podaj nick: \n"); scanf("%s", message.nick); break; case 2: //printf("Uzytkownicy: \n"); break; case 3: //printf("Grupy: \n"); break; case 4: printf("Zmien nick: \n"); scanf("%s", message.nick); break; case 5: printf("Dolacz do grupy. Podaj nazwe grupy: \n"); scanf("%s", message.nick); break; case 6: printf("Wypisz sie z grupy. Podaj nazwe grupy: \n"); scanf("%s", message.nick); break; case 8: printf("Wyswietl chat. \n "); ShowChat(message, m, server); break; case 9: printf("Wyslij wiadomosc do grupy. Podaj nazwe grupy: \n"); scanf("%s", message.nick); i=0; strcpy(message.text, ""); //clear old msg while( (symbol = getchar()) != '\n') { //clean buffer } printf("Podaj wiadomosc: \n"); symbol=getchar(); while(( (symbol != '\n') && (i <256) )){ printf("Moje i to: %d", i); message.text[i++]=symbol; symbol = getchar(); } message.text[i]=0; break; case 10: printf("Wyloguj \n"); break; } message = InitTasks(message, task); msgsnd(server, &message, sizeof(message), 0); msgrcv(server, &message, sizeof(message), getpid(), MSG_NOERROR); CheckStatus(message); CheckCMD(message); } return 0; }
CChatItem* CChatSelector::StartSession(CUpDownClient* pClient, bool bForceFocus /* true */) { if (pClient == NULL || !g_App.m_pMDlg->IsRunning()) return NULL; EMULE_TRY if (GetTabByClient(pClient) != (uint16)-1) { SetCurSel(GetTabByClient(pClient)); if (bForceFocus) ShowChat(); return NULL; } CChatItem *pChatItem = new CChatItem(); CRect rcRect; pChatItem->m_pClient = pClient; pChatItem->m_pLog = new CHTRichEditCtrl; GetClientRect(&rcRect); AdjustRect(false, rcRect); rcRect.left += 3; rcRect.top += 4; rcRect.right -= 3; rcRect.bottom -= 3; if (GetItemCount() == 0) rcRect.top += 20; pChatItem->m_pLog->Create(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | ES_READONLY | ES_NOHIDESEL, rcRect, this, (UINT)-1); pChatItem->m_pLog->ModifyStyleEx(0, WS_EX_STATICEDGE, SWP_FRAMECHANGED); pChatItem->m_pLog->SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(3, 3)); pChatItem->m_pLog->SetFont(&g_App.m_pMDlg->m_fontDefault); pChatItem->m_pLog->m_dwFlags |= HTC_ISWORDWRAP; pChatItem->m_pLog->SetTargetDevice(NULL, 0); COleDateTime timelog(COleDateTime::GetCurrentTime()); CString strName = pClient->GetUserName(), strCountry, strTemp; if (g_App.m_pIP2Country->IsIP2Country()) strCountry.Format(_T(" (%s)"), pClient->GetCountryName()); strTemp.Format(_T("*** %s: %s (%s: %s:%u%s) - %s\n"), GetResString(IDS_CHAT_START), strName, GetResString(IDS_IP), pClient->GetFullIP(), pClient->GetUserPort(), strCountry, timelog.Format(_T("%c"))); pChatItem->m_pLog->AppendText(strTemp, RGB(255, 0, 0)); pClient->SetChatState(MS_CHATTING); if (pClient->IsFriend()) pClient->m_pFriend->m_dwLastChatted = time(NULL); if (strName.GetLength() > 30) { strName.Truncate(30); strName += _T("..."); } else if (strName.IsEmpty()) strName.Format(_T("[%s]"), GetResString(IDS_UNKNOWN)); TCITEM tcitem; tcitem.mask = TCIF_PARAM | TCIF_TEXT | TCIF_IMAGE; tcitem.lParam = (LPARAM)pChatItem; tcitem.pszText = (TCHAR*)strName.GetString(); tcitem.iImage = 0; int iResult = InsertItem(GetItemCount(), &tcitem); g_App.m_pMDlg->m_wndChat.m_ctlCloseButton.EnableWindow(true); g_App.m_pMDlg->m_wndChat.m_ctlSendButton.EnableWindow(true); if (iResult != -1 && IsWindowVisible()) { SetCurSel(iResult); pChatItem->m_pLog->SetTitle(pClient->GetUserName()); if (bForceFocus) ShowChat(); } return pChatItem; EMULE_CATCH return NULL; }