From: <ane...@us...> - 2013-06-04 23:49:00
|
Revision: 943 http://sourceforge.net/p/vision/code/943 Author: anevilyak Date: 2013-06-04 23:48:57 +0000 (Tue, 04 Jun 2013) Log Message: ----------- - Remove obsolete InfoPopper support. - Backport support for Haiku's notifications. Modified Paths: -------------- branches/0.9.7/Makefile branches/0.9.7/src/ChannelAgent.cpp branches/0.9.7/src/MessageAgent.cpp branches/0.9.7/src/ParseENums.cpp Modified: branches/0.9.7/Makefile =================================================================== --- branches/0.9.7/Makefile 2013-05-31 01:34:17 UTC (rev 942) +++ branches/0.9.7/Makefile 2013-06-04 23:48:57 UTC (rev 943) @@ -16,7 +16,7 @@ # the file name, ... BINARY := Vision -VERSION := 0.9.7-H-130530 +VERSION := 0.9.7-H-130604 BUILDDATE := $(shell date +%b_%d_%Y) BUILD_TYPE := Release Modified: branches/0.9.7/src/ChannelAgent.cpp =================================================================== --- branches/0.9.7/src/ChannelAgent.cpp 2013-05-31 01:34:17 UTC (rev 942) +++ branches/0.9.7/src/ChannelAgent.cpp 2013-06-04 23:48:57 UTC (rev 943) @@ -1,21 +1,21 @@ -/* - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing + * implied. See the License for the specific language governing * rights and limitations under the License. - * - * The Original Code is Vision. - * + * + * The Original Code is Vision. + * * The Initial Developer of the Original Code is The Vision Team. * Portions created by The Vision Team are * Copyright (C) 1999, 2000, 2001 The Vision Team. All Rights * Reserved. - * + * * Contributor(s): Wade Majors <wa...@ez...> * Rene Gollent * Todd Lair @@ -27,6 +27,7 @@ #include <Beep.h> #include <FilePanel.h> #include <MenuItem.h> +#include <Notification.h> #include <PopUpMenu.h> #include <Roster.h> #include <ScrollView.h> @@ -44,10 +45,6 @@ #include "ChannelOptions.h" #include "ResizeView.h" -#ifdef USE_INFOPOPPER -#include <infopopper/InfoPopper.h> -#endif - ChannelAgent::ChannelAgent ( const char *id_, const char *serverName_, @@ -76,7 +73,7 @@ { /* * Function purpose: Consctruct - */ + */ } ChannelAgent::~ChannelAgent (void) @@ -84,13 +81,13 @@ /* * Function purpose: Clean up */ - + fNamesList->ClearList(); - + // empty recent nick list while (fRecentNicks.CountItems() > 0) delete fRecentNicks.RemoveItemAt(0L); - + // empty nick completion list while (fCompletionNicks.CountItems() > 0) delete fCompletionNicks.RemoveItemAt(0L); @@ -103,7 +100,7 @@ * Function purpose: Once the BView has been successfully attached, call Init() */ - + Init(); ClientAgent::AttachedToWindow(); } @@ -114,20 +111,20 @@ /* * Function purpose: Setup everything */ - + const BRect namesRect (vision_app->GetRect ("nameListRect")); fTextScroll->ResizeTo ( Frame().Width() - ((namesRect.Width() == 0.0) ? 100 : namesRect.Width()), fTextScroll->Frame().Height()); - + fFrame = Bounds(); fFrame.left = fTextScroll->Frame().right + 6; fFrame.right -= B_V_SCROLL_BAR_WIDTH + 1; fFrame.bottom = fTextScroll->Frame().bottom - 1; - + fNamesList = new NamesView (fFrame); - + fNamesScroll = new BScrollView( "scroll_names", fNamesList, @@ -164,7 +161,7 @@ fNamesScroll->MoveBy (difference, 0.0); Sync(); } - + ClientAgent::Show(); } @@ -176,19 +173,19 @@ * Function purpose: Find the index of nickname {data} in the * ChannelAgent's NamesView */ - + if (fNamesList == NULL) return -1; - + int32 count (fNamesList->CountItems()); for (int32 i = 0; i < count; ++i) { NameItem *item (static_cast<NameItem *>(fNamesList->ItemAt (i))); - + if (item == NULL) continue; - + BString nick (item->Name()); if ((nick[0] == '@' || nick[0] == '+' || nick[0] == '%') @@ -230,7 +227,7 @@ ChannelAgent::AddUser (const char *nick, const int32 status) { NameItem *compareItem (NULL); - + // make sure this nick doesn't already exist in the list // can happen since some ircds allow stealth quits that don't // broadcast a quit message @@ -241,7 +238,7 @@ if (compareItem && compareItem->Name().ICompare(nick) == 0) return; } - + fNamesList->AddItem (new NameItem (nick, status)); fNamesList->SortItems (SortNames); @@ -249,7 +246,7 @@ BString buffer; buffer << fUserCount; BString *comparator (NULL); - + // check if new nickname matches against tab completion sequence and update nick list // if so if (fLastExpansion.Length() > 0 && fLastExpansion.ICompare(nick, fLastExpansion.Length()) == 0) @@ -259,14 +256,14 @@ { comparator = fCompletionNicks.ItemAt (i); if (comparator && comparator->ICompare (nick) < 0) - { + { BString *string (new BString (nick)); fCompletionNicks.AddItem (string, i+1); break; } } } - + if (!IsHidden()) vision_app->pClientWin()->pStatusView()->SetItemValue (STATUS_USERS, buffer.String()); } @@ -279,15 +276,15 @@ * Function purpose: Remove nickname {data} from the ChannelAgent's * NamesView and update the status counts */ - - + + if (fNamesList == NULL) return false; - + // if nickname is present in tab completion lists, remove RemoveNickFromList(fRecentNicks, data); RemoveNickFromList(fCompletionNicks, data); - + int32 myIndex (FindPosition (data)); if (myIndex >= 0) @@ -303,7 +300,7 @@ { --fOpsCount; buffer << fOpsCount; - + if (!IsHidden()) vision_app->pClientWin()->pStatusView()->SetItemValue (STATUS_OPS, buffer.String()); @@ -314,12 +311,12 @@ buffer << fUserCount; if (!IsHidden()) vision_app->pClientWin()->pStatusView()->SetItemValue (STATUS_USERS, buffer.String()); - + delete item; return true; } } - + return false; } @@ -353,9 +350,9 @@ * * uses strict lexicographic order, ignores the op/voice bits */ - + // clunky way to get around C++ warnings re casting from const void * to NameItem * - + // Not sure if this can happen, and we // are assuming that if one is NULL // we return them as equal. What if one @@ -380,9 +377,9 @@ * Voiced * Normal User */ - + // clunky way to get around C++ warnings re casting from const void * to NameItem * - + const NameItem *firstPtr (*((NameItem * const *)name1)); const NameItem *secondPtr (*((NameItem * const *)name2)); @@ -412,9 +409,9 @@ /* * Function purpose: Get the characters before the caret's current position, * and update the fInput VTextControl with a relevant match - * from the ChannelAgent's NamesView + * from the ChannelAgent's NamesView */ - + int32 start, finish; static int32 lastindex; static BString lastNick; @@ -444,10 +441,10 @@ while (!fCompletionNicks.IsEmpty()) delete fCompletionNicks.RemoveItemAt(0L); - + int32 count (fNamesList->CountItems()), i (0); - + for (i = 0; i < count ; i++) { BString *name (new BString(static_cast<NameItem *>(fNamesList->ItemAt(i))->Name())); @@ -458,7 +455,7 @@ } // sort items alphabetically fCompletionNicks.SortItems (AlphaSortNames); - + count = fRecentNicks.CountItems(); // parse recent nicks in reverse to ensure that they're pushed onto the completion // list in the correct order @@ -482,7 +479,7 @@ delete name; } } - + // We first check if what the user typed matches the channel // If that doesn't match, we check the names BString insertion; @@ -495,7 +492,7 @@ if (count > 0) { insertion = *(fCompletionNicks.ItemAt(lastindex++)); - + if (lastindex == count) lastindex = 0; lastNick = insertion; } @@ -544,7 +541,7 @@ ChannelAgent::MessageReceived (BMessage *msg) { int32 i (0); - + switch (msg->what) { case M_USER_QUIT: @@ -552,11 +549,11 @@ const char *nick (NULL); msg->FindString ("nick", &nick); - + if (RemoveUser (nick)) { BMessage display; - + if (msg->FindMessage ("display", &display) == B_NO_ERROR) ClientAgent::MessageReceived (&display); } @@ -567,7 +564,7 @@ { const char *nick (NULL); bool ignore (false); - + int32 iStatus (STATUS_NORMAL_BIT); msg->FindString ("nick", &nick); @@ -579,7 +576,7 @@ } if (ignore) iStatus |= STATUS_IGNORE_BIT; - + AddUser (nick, iStatus); BMessage display; @@ -613,7 +610,7 @@ { int32 count (fRecentNicks.CountItems()); BString *name (NULL); - + for (i = 0; i < count ; i++) if ((name = fRecentNicks.ItemAt (i))->ICompare (oldNick) == 0) { @@ -637,7 +634,7 @@ } else break; - + ClientAgent::MessageReceived (msg); } break; @@ -661,11 +658,11 @@ msg->FindBool ("voice", i, &voice); msg->FindBool ("helper", i, &helper); msg->FindBool ("ignored", i, &ignored); - + if (FindPosition (nick) < 0) { int32 iStatus (ignored ? STATUS_IGNORE_BIT : 0); - + if (founder) { ++nick; @@ -696,13 +693,13 @@ } else iStatus |= STATUS_NORMAL_BIT; - + fUserCount++; - + fNamesList->AddItem (new NameItem (nick, iStatus)); } } - + fNamesList->SortItems (SortNames); if (!IsHidden()) @@ -717,7 +714,7 @@ } } break; - + case M_RESIZE_VIEW: { BPoint point; @@ -739,20 +736,20 @@ fNamesList->ClearList(); fOpsCount = 0; fUserCount = 0; - + // clear heuristics completion list - this ensures that no stale nicks are left // over in it after reconnect -- list will quickly be rebuilt anyhow if there // is any conversation whatsoever going on while (fRecentNicks.CountItems() > 0) delete fRecentNicks.RemoveItemAt(0L); - + } break; - + case M_REJOIN: { const char *newNick (NULL); - + if (msg->FindString ("nickname", &newNick) != B_OK) { printf("Error: ChannelAgent::MessageReceived, M_REJOIN: invalid pointer\n"); @@ -760,16 +757,16 @@ } fMyNick = newNick; // update nickname (might have changed on reconnect) - + if (!IsHidden()) vision_app->pClientWin()->pStatusView()->SetItemValue (STATUS_NICK, fMyNick.String()); - + Display (S_CHANNEL_RECON_REJOIN B_UTF8_ELLIPSIS "\n", C_ERROR, C_BACKGROUND, F_SERVER); - // send join cmd - BMessage send (M_SERVER_SEND); + // send join cmd + BMessage send (M_SERVER_SEND); AddSend (&send, "JOIN "); - AddSend (&send, fId); + AddSend (&send, fId); if (fChanKey != "") { AddSend (&send, " "); @@ -778,7 +775,7 @@ AddSend (&send, endl); } break; - + case M_CHANNEL_TOPIC: { const char *theTopic (NULL); @@ -790,12 +787,12 @@ break; } fTopic = theTopic; - + if (!IsHidden()) vision_app->pClientWin()->pStatusView()->SetItemValue (STATUS_META, FilterCrap(theTopic, true).String()); BMessage display; - + if (msg->FindMessage ("display", &display) == B_NO_ERROR) ClientAgent::MessageReceived (&display); } @@ -805,7 +802,7 @@ { const char *theNick (NULL); msg->FindString("nick", &theNick); - + if (theNick == NULL) { NameItem *myUser; @@ -817,7 +814,7 @@ msg->AddString ("nick", targetNick.String()); } } - + fSMsgr.SendMessage (msg); } break; @@ -826,14 +823,14 @@ { const char *theChannel (NULL), *kicker (NULL), *rest (NULL); - + if ((msg->FindString ("channel", &theChannel) != B_OK) || - (msg->FindString ("kicker", &kicker) != B_OK) || + (msg->FindString ("kicker", &kicker) != B_OK) || (msg->FindString ("rest", &rest) != B_OK)) { printf("Error: ClientAgent::MessageReceived, M_CHANNEL_GOT_KICKED, invalid pointer\n"); break; - } + } BMessage wegotkicked (M_DISPLAY); // "you were kicked" BString buffer; @@ -850,7 +847,7 @@ fNamesList->ClearList(); fOpsCount = 0; fUserCount = 0; - + fMsgr.SendMessage (&wegotkicked); BMessage attemptrejoin (M_DISPLAY); // "you were kicked" @@ -867,7 +864,7 @@ { AddSend (&send, " "); AddSend (&send, fChanKey); - } + } AddSend (&send, endl); } break; @@ -877,7 +874,7 @@ ModeEvent (msg); } break; - + case M_CHANNEL_MSG: { bool hasNick (false); @@ -888,38 +885,30 @@ msg->FindString ("nick", &theNick); if (theNick != fMyNick) FirstKnownAs (tempString, knownAs, &hasNick); - + if (IsHidden()) { UpdateStatus((hasNick) ? WIN_NICK_BIT : WIN_NEWS_BIT); -#ifdef USE_INFOPOPPER + if (hasNick) { - if (tempString[0] == '\1') - { - tempString.RemoveFirst("\1ACTION "); - tempString.RemoveLast ("\1"); - } + if (tempString[0] == '\1') + { + tempString.RemoveFirst("\1ACTION "); + tempString.RemoveLast ("\1"); + } - if (be_roster->IsRunning(InfoPopperAppSig) == true) { - entry_ref ref = vision_app->AppRef(); - BMessage infoMsg(InfoPopper::AddMessage); - infoMsg.AddString("appTitle", S_INFOPOPPER_TITLE); - infoMsg.AddString("title", fServerName.String()); - infoMsg.AddInt8("type", (int8)InfoPopper::Important); - - infoMsg.AddInt32("iconType", InfoPopper::Attribute); - infoMsg.AddRef("iconRef", &ref); - - BString content; - content << fId << " - " << theNick << " said: " << tempString; - infoMsg.AddString("content", content); - - BMessenger(InfoPopperAppSig).SendMessage(&infoMsg); - }; + BNotification notification(B_INFORMATION_NOTIFICATION); + notification.SetGroup(BString("Vision")); + entry_ref ref = vision_app->AppRef(); + notification.SetOnClickFile(&ref); + notification.SetTitle(fServerName.String()); + BString content; + content.SetToFormat("%s - %s said: %s", + fId.String(), theNick.String(), tempString.String()); + notification.SetContent(content); + notification.Send(); } -#endif - } else if (hasNick) system_beep(kSoundEventNames[(uint32)seNickMentioned]); @@ -933,7 +922,7 @@ const char *mode (NULL), *chan (NULL), *msgz (NULL); - + if ((msg->FindString ("mode", &mode) != B_OK) || (msg->FindString ("chan", &chan) != B_OK) || (msg->FindString ("msgz", &msgz) != B_OK)) @@ -946,21 +935,21 @@ { BString realMode (GetWord (mode, 1)); int32 place (2); - + if (realMode.FindFirst ("l") >= 0) fChanLimit = GetWord (mode, place++); if (realMode.FindFirst ("k") >= 0) { fChanKey = GetWord (mode, place++); - + // u2 may not send the channel key, thats why we stored the /join cmd // in a string in ParseCmd if (fChanKey == "*" && fIrcdtype == IRCD_UNDERNET) { BString tempId (fId); tempId.Remove (0, 1); // remove any #, &, !, blah. - + if (vision_app->pClientWin()->joinStrings.FindFirst (tempId) < 1) { // can't find the join cmd for this channel in joinStrings! @@ -968,23 +957,23 @@ else { BString joinStringsL (vision_app->pClientWin()->joinStrings); - + // FindLast to make sure we get the last attempt (user might have // tried several keys) - int32 idPos (joinStringsL.FindLast (tempId)); + int32 idPos (joinStringsL.FindLast (tempId)); BString tempKeyString; joinStringsL.MoveInto (tempKeyString, idPos, joinStringsL.Length()); - + fChanKey = GetWord (tempKeyString.String(), 2); } } // end u2-kludge stuff - + } fChanMode = mode; if (!IsHidden()) - vision_app->pClientWin()->pStatusView()->SetItemValue (STATUS_MODES, fChanMode.String()); + vision_app->pClientWin()->pStatusView()->SetItemValue (STATUS_MODES, fChanMode.String()); } - + BMessage dispMsg (M_DISPLAY); PackDisplay (&dispMsg, msgz, C_OP, C_BACKGROUND, F_TEXT); BMessenger display (this); @@ -995,17 +984,17 @@ case M_NAMES_POPUP_MODE: { const char *inaction (NULL); - + msg->FindString ("action", &inaction); int32 count (0), index (0); - + BString victims, targetNick, action (inaction), modechar, polarity; - + NameItem *myUser (NULL); /// action /// @@ -1024,7 +1013,7 @@ /// iterate /// while ((i = fNamesList->CurrentSelection (index++)) >= 0) - { + { myUser = static_cast<NameItem *>(fNamesList->ItemAt (i)); targetNick = myUser->Name(); @@ -1042,7 +1031,7 @@ command += modechar; command += victims; - + ParseCmd (command.String()); } break; @@ -1050,7 +1039,7 @@ case M_NAMES_POPUP_CTCP: { const char *inaction (NULL); - + msg->FindString ("action", &inaction); int32 index (0); @@ -1062,14 +1051,14 @@ /// iterate /// while ((i = fNamesList->CurrentSelection (index++)) >= 0) - { + { myUser = static_cast<NameItem *>(fNamesList->ItemAt (i)); targetNick = myUser->Name(); victims += targetNick; victims += ","; } - + victims.RemoveLast (","); BString command ("/ctcp "); @@ -1090,7 +1079,7 @@ /// iterate /// while ((i = fNamesList->CurrentSelection (index++)) >= 0) - { + { myUser = static_cast<NameItem *>(fNamesList->ItemAt (i)); targetNick = myUser->Name(); @@ -1099,14 +1088,14 @@ } victims.RemoveLast (","); - + BString command ("/whois "); command += victims; ParseCmd (command.String()); } break; - + case M_NAMES_POPUP_NOTIFY: { int32 index (0); @@ -1116,7 +1105,7 @@ /// iterate /// while ((i = fNamesList->CurrentSelection (index++)) >= 0) - { + { myUser = static_cast<NameItem *>(fNamesList->ItemAt (i)); targetNick = myUser->Name(); @@ -1125,7 +1114,7 @@ } victims.RemoveLast (","); - + BString command ("/notify "); command += victims; @@ -1134,43 +1123,43 @@ } break; - case M_NAMES_POPUP_DCCCHAT: - { - int32 index (0); - BString targetNick; - NameItem *myUser (NULL); + case M_NAMES_POPUP_DCCCHAT: + { + int32 index (0); + BString targetNick; + NameItem *myUser (NULL); - /// iterate /// - while ((i = fNamesList->CurrentSelection(index++)) >= 0) - { - myUser = static_cast<NameItem *>(fNamesList->ItemAt(i)); - targetNick = myUser->Name(); - - BString command ("/dcc chat "); - command += targetNick; + /// iterate /// + while ((i = fNamesList->CurrentSelection(index++)) >= 0) + { + myUser = static_cast<NameItem *>(fNamesList->ItemAt(i)); + targetNick = myUser->Name(); - ParseCmd (command.String()); - } - } + BString command ("/dcc chat "); + command += targetNick; + + ParseCmd (command.String()); + } + } break; - + case M_NAMES_POPUP_DCCSEND: { - int32 index (0); - BString targetNick; - NameItem *myUser (NULL); + int32 index (0); + BString targetNick; + NameItem *myUser (NULL); - /// iterate /// - while ((i = fNamesList->CurrentSelection(index++)) >= 0) - { - myUser = static_cast<NameItem *>(fNamesList->ItemAt(i)); - targetNick = myUser->Name(); - - BString command ("/dcc send "); - command += targetNick; + /// iterate /// + while ((i = fNamesList->CurrentSelection(index++)) >= 0) + { + myUser = static_cast<NameItem *>(fNamesList->ItemAt(i)); + targetNick = myUser->Name(); - ParseCmd (command.String()); - } + BString command ("/dcc send "); + command += targetNick; + + ParseCmd (command.String()); + } } break; @@ -1179,14 +1168,14 @@ int32 index (0); BString targetNick, kickMsg (vision_app->GetCommand (CMD_KICK)); - NameItem *myUser (NULL); + NameItem *myUser (NULL); /// iterate /// while ((i = fNamesList->CurrentSelection(index++)) >= 0) - { + { myUser = static_cast<NameItem *>(fNamesList->ItemAt(i)); targetNick = myUser->Name(); - + BString command ("/kick "); command += targetNick; command += " "; @@ -1201,7 +1190,7 @@ { vision_app->pClientWin()->pStatusView()->AddItem (new StatusItem ( 0, ""), true); - + vision_app->pClientWin()->pStatusView()->AddItem (new StatusItem ( S_STATUS_LAG, "", STATUS_ALIGN_LEFT), true); @@ -1270,7 +1259,7 @@ AddSend (&send, msg->FindString("vision:partmsg")); } AddSend (&send, endl); - } + } ClientAgent::MessageReceived(msg); } break; @@ -1286,7 +1275,7 @@ /* * Function purpose: Send the text in {buffer} to the server */ - + fLastExpansion = ""; // used by ChannelAgent::TabExpansion() BMessage send (M_SERVER_SEND); @@ -1297,13 +1286,13 @@ Display ("<", C_MYNICK); Display (fMyNick.String(), C_NICKDISPLAY); - Display ("> ", C_MYNICK); - + Display ("> ", C_MYNICK); + BString sBuffer (buffer); - + AddSend (&send, sBuffer.String()); AddSend (&send, endl); - + Display (sBuffer.String()); Display ("\n"); } @@ -1315,7 +1304,7 @@ memset(modeString, 0, sizeof(modeString)); sprintf (modeString, "%c", theMode); BString myTemp; - + if (theSign == '-') { switch (theMode) @@ -1344,7 +1333,7 @@ } break; } - + fChanMode.RemoveFirst (modeString); } else @@ -1368,7 +1357,7 @@ theOld += fChanLimitOld; tempString.RemoveFirst (theOld); } - + tempString.Append (" "); tempString.Append (fChanLimit); fChanLimitOld = fChanLimit; @@ -1381,12 +1370,12 @@ theOld += fChanKeyOld; tempString.RemoveFirst (theOld); } - + tempString.Append (" "); tempString.Append (fChanKey); fChanKeyOld = fChanKey; } - + fChanMode = tempString; } @@ -1485,7 +1474,7 @@ buffer = ""; buffer << fOpsCount; - + if (!IsHidden()) vision_app->pClientWin()->pStatusView()->SetItemValue (STATUS_OPS, buffer.String()); } @@ -1510,13 +1499,13 @@ if (theOperator == '+' && theModifier == 'h') { hit = true; - + item->SetStatus ((iStatus & ~STATUS_NORMAL_BIT) | STATUS_HELPER_BIT); } else if (theModifier == 'h') { hit = true; - + iStatus &= ~STATUS_HELPER_BIT; if ((iStatus & STATUS_HELPER_BIT) == 0) iStatus |= STATUS_NORMAL_BIT; @@ -1548,7 +1537,7 @@ fChanKey = myTarget; UpdateMode ('+', 'k'); } - else if (theModifier == 'b' || theModifier == 'a' || theModifier == 'q') + else if (theModifier == 'b' || theModifier == 'a' || theModifier == 'q') { // dont do anything else } @@ -1562,7 +1551,7 @@ || mode[modPos] == '-') theOperator = mode[modPos++]; } - + if (hit) { fNamesList->SortItems (SortNames); Modified: branches/0.9.7/src/MessageAgent.cpp =================================================================== --- branches/0.9.7/src/MessageAgent.cpp 2013-05-31 01:34:17 UTC (rev 942) +++ branches/0.9.7/src/MessageAgent.cpp 2013-06-04 23:48:57 UTC (rev 943) @@ -1,21 +1,21 @@ -/* - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * * The Original Code is Vision. - * + * * The Initial Developer of the Original Code is The Vision Team. * Portions created by The Vision Team are * Copyright (C) 1999, 2000, 2001 The Vision Team. All Rights * Reserved. - * + * * Contributor(s): Wade Majors <wa...@ez...> * Rene Gollent * Todd Lair @@ -26,10 +26,11 @@ #include <Beep.h> #include <Entry.h> #include <MenuItem.h> +#include <Notification.h> #include <PopUpMenu.h> #include <Roster.h> #include <UTF8.h> - + #include "MessageAgent.h" #include "WindowList.h" #include "ClientWindow.h" @@ -45,10 +46,6 @@ #include <sys/select.h> #include <arpa/inet.h> -#ifdef USE_INFOPOPPER -#include <infopopper/InfoPopper.h> -#endif - MessageAgent::MessageAgent ( BRect &frame_, const char *id_, @@ -103,7 +100,7 @@ fDataThread = spawn_thread(DCCIn, "DCC Chat(I)", B_NORMAL_PRIORITY, this); else fDataThread = spawn_thread(DCCOut, "DCC Chat(O)", B_NORMAL_PRIORITY, this); - + resume_thread (fDataThread); } ClientAgent::AllAttached(); @@ -143,22 +140,22 @@ int32 diff (atoi(vision_app->GetString ("dccMaxPort")) - myPort); if (diff > 0) myPort += rand() % diff; - + BString outNick (fChatee); outNick.RemoveFirst (" [DCC]"); struct sockaddr_in sa; - + BMessage reply; fSMsgr.SendMessage (M_GET_IP, &reply); - + BString address; reply.FindString ("ip", &address); - + if (fDPort != "") myPort = atoi (fDPort.String()); fMySocket = socket (AF_INET, SOCK_STREAM, 0); - + BMessage statMsg (M_DISPLAY); if (fMySocket < 0) @@ -171,35 +168,35 @@ sa.sin_family = AF_INET; sa.sin_addr.s_addr = INADDR_ANY; - + sa.sin_port = htons(myPort); - + if (bind (fMySocket, (struct sockaddr*)&sa, sizeof(sa)) == -1) { ClientAgent::PackDisplay (&statMsg, S_DCC_BIND_ERROR, C_ERROR); fMsgr.SendMessage (&statMsg); return; } - + BMessage sendMsg (M_SERVER_SEND); BString buffer; - + sa.sin_addr.s_addr = inet_addr (address.String()); - + buffer << "PRIVMSG " << outNick << " :\1DCC CHAT chat "; buffer << htonl(sa.sin_addr.s_addr) << " "; buffer << myPort << "\1"; sendMsg.AddString ("data", buffer.String()); fSMsgr.SendMessage (&sendMsg); - - vision_app->AcquireDCCLock(); + + vision_app->AcquireDCCLock(); listen (fMySocket, 1); BString dataBuffer; struct in_addr addr; - + addr.s_addr = inet_addr (address.String()); - dataBuffer << S_DCC_CHAT_LISTEN + dataBuffer << S_DCC_CHAT_LISTEN << address.String() << S_DCC_CHAT_PORT << myPort << "\n"; ClientAgent::PackDisplay (&statMsg, dataBuffer.String(), C_TEXT); fMsgr.SendMessage (&statMsg); @@ -213,23 +210,23 @@ BMessenger fSMsgrE (agent->fSMsgr); BMessenger mMsgr (agent); agent->DCCServerSetup(); - + int dccSocket (agent->fMySocket); int dccAcceptSocket (0); - + struct sockaddr_in remoteAddy; int theLen (sizeof (struct sockaddr_in)); dccAcceptSocket = accept(dccSocket, (struct sockaddr*)&remoteAddy, (socklen_t *)&theLen); - + vision_app->ReleaseDCCLock(); - + if (dccAcceptSocket < 0) return B_ERROR; - + agent->fAcceptSocket = dccAcceptSocket; agent->fDConnected = true; - + BMessage msg (M_DISPLAY); ClientAgent::PackDisplay (&msg, S_DCC_CHAT_CONNECTED); @@ -238,13 +235,13 @@ char tempBuffer[2]; BString inputBuffer; int32 recvReturn (0); - + struct fd_set rset, eset; FD_ZERO (&rset); FD_ZERO (&eset); FD_SET (dccAcceptSocket, &rset); FD_SET (dccAcceptSocket, &eset); - + while (mMsgr.IsValid() && agent->fDConnected) { if (select (dccAcceptSocket + 1, &rset, NULL, &eset, NULL) > 0) @@ -272,17 +269,17 @@ destLength (sizeof(convBuffer)), state (0); int32 encoding = vision_app->GetInt32("encoding"); - if (encoding != B_UNICODE_CONVERSION) + if (encoding != B_UNICODE_CONVERSION) { convert_to_utf8 ( encoding, - inputBuffer.String(), + inputBuffer.String(), &length, convBuffer, &destLength, &state); - } - else + } + else { if (IsValidUTF8(inputBuffer.String(), length)) { @@ -293,7 +290,7 @@ { convert_to_utf8 ( B_ISO1_CONVERSION, - inputBuffer.String(), + inputBuffer.String(), &length, convBuffer, &destLength, @@ -322,7 +319,7 @@ FD_SET (dccAcceptSocket, &rset); FD_SET (dccAcceptSocket, &eset); } - + return 0; } @@ -330,13 +327,13 @@ MessageAgent::DCCOut (void *arg) { MessageAgent *agent ((MessageAgent *)arg); - + BMessenger mMsgr (agent); struct sockaddr_in sa; int status; int dccAcceptSocket (0); char *endpoint; - + uint32 realIP = strtoul (agent->fDIP.String(), &endpoint, 10); if ((dccAcceptSocket = socket(AF_INET, SOCK_STREAM, 0)) < 0) @@ -347,9 +344,9 @@ mMsgr.SendMessage (&msg); return false; } - + agent->fAcceptSocket = dccAcceptSocket; - + sa.sin_family = AF_INET; sa.sin_port = htons (atoi (agent->fDPort.String())); sa.sin_addr.s_addr = ntohl (realIP); @@ -365,7 +362,7 @@ buffer << S_DCC_CHAT_TRY << inet_ntoa (addr) << S_DCC_CHAT_PORT << agent->fDPort << "\n"; - + ClientAgent::PackDisplay (&msg, buffer.String()); mMsgr.SendMessage (&msg); } @@ -398,7 +395,7 @@ FD_ZERO (&eset); FD_SET (dccAcceptSocket, &rset); FD_SET (dccAcceptSocket, &eset); - + while (mMsgr.IsValid() && agent->fDConnected) { if (select (dccAcceptSocket + 1, &rset, NULL, &eset, &tv) > 0) @@ -424,14 +421,14 @@ int32 length (inputBuffer.Length()), destLength (sizeof(convBuffer)), state (0); - + convert_to_utf8 ( - vision_app->GetInt32("encoding"), inputBuffer.String(), + vision_app->GetInt32("encoding"), inputBuffer.String(), &length, convBuffer, &destLength, &state); - + BMessage dispMsg (M_CHANNEL_MSG); dispMsg.AddString ("msgz", inputBuffer.String()); mMsgr.SendMessage (&dispMsg); @@ -454,7 +451,7 @@ FD_SET (dccAcceptSocket, &rset); FD_SET (dccAcceptSocket, &eset); } - + return 0; } @@ -466,7 +463,7 @@ const char *address) { // fAgentWinItem->SetName (nick); - + ClientAgent::ChannelMessage (msgz, nick, ident, address); } @@ -483,26 +480,26 @@ // and update DCC send logic to figure that out too entry_ref ref; msg->FindRef("refs", &ref); - + BMessage dccmsg(M_CHOSE_FILE); dccmsg.AddString("nick", fChatee.String()); dccmsg.AddRef("refs", &ref); - fSMsgr.SendMessage(&dccmsg); + fSMsgr.SendMessage(&dccmsg); } } break; - + case M_CHANNEL_MSG: { const char *nick (NULL); - + if (msg->HasString ("nick")) { msg->FindString ("nick", &nick); BString outNick (nick); outNick.RemoveFirst (" [DCC]"); if (fMyNick.ICompare (outNick) != 0 && !fDChat) - fAgentWinItem->SetName (outNick.String()); + fAgentWinItem->SetName (outNick.String()); msg->ReplaceString ("nick", outNick.String()); } else @@ -516,34 +513,25 @@ if (IsHidden()) UpdateStatus (WIN_NICK_BIT); - + if (IsHidden() || (window && !window->IsActive())) { -#ifdef USE_INFOPOPPER - if (be_roster->IsRunning(InfoPopperAppSig) == true) { - entry_ref ref = vision_app->AppRef(); - BMessage infoMsg(InfoPopper::AddMessage); - infoMsg.AddString("appTitle", S_INFOPOPPER_TITLE); - infoMsg.AddString("title", fServerName.String()); - infoMsg.AddInt8("type", (int8)InfoPopper::Important); - - infoMsg.AddInt32("iconType", InfoPopper::Attribute); - infoMsg.AddRef("iconRef", &ref); + BNotification notification(B_INFORMATION_NOTIFICATION); + notification.SetGroup(BString("Vision")); + entry_ref ref = vision_app->AppRef(); + notification.SetOnClickFile(&ref); + notification.SetTitle(fServerName.String()); + BString tempString(msg->FindString("msgz")); + if (tempString[0] == '\1') + { + tempString.RemoveFirst("\1ACTION "); + tempString.RemoveLast ("\1"); + } - BString tempString(msg->FindString("msgz")); - if (tempString[0] == '\1') - { - tempString.RemoveFirst("\1ACTION "); - tempString.RemoveLast ("\1"); - } - - BString content; - content << nick << " said: " << tempString.String(); - infoMsg.AddString("content", content); - - BMessenger(InfoPopperAppSig).SendMessage(&infoMsg); - }; -#endif + BString content; + content.SetToFormat("%s said: %s", nick, tempString.String()); + notification.SetContent(content); + notification.Send(); } if (window != NULL && !window->IsActive()) @@ -553,7 +541,7 @@ ClientAgent::MessageReceived (msg); } break; - + case M_MSG_WHOIS: { BMessage dataSend (M_SERVER_SEND); @@ -562,7 +550,7 @@ AddSend (&dataSend, fChatee.String()); AddSend (&dataSend, " "); AddSend (&dataSend, fChatee.String()); - AddSend (&dataSend, endl); + AddSend (&dataSend, endl); } case M_CHANGE_NICK: @@ -585,7 +573,7 @@ if (fDChat) fId.Append(" [DCC]"); - + // set up new logging file for new nick BMessage logMsg (M_UNREGISTER_LOGGER); logMsg.AddString("name", oldId.String()); @@ -594,13 +582,13 @@ logMsg.what = M_REGISTER_LOGGER; logMsg.AddString("name", fId.String()); fSMsgr.SendMessage(&logMsg); - + fAgentWinItem->SetName (fId.String()); - + ClientAgent::MessageReceived (msg); } - + else if (fMyNick.ICompare (oldNick) == 0) { if (!IsHidden()) @@ -615,13 +603,13 @@ vision_app->pClientWin()->pStatusView()->AddItem (new StatusItem ( 0, ""), true); - + vision_app->pClientWin()->pStatusView()->AddItem (new StatusItem ( "Lag: ", "", STATUS_ALIGN_LEFT), true); - + vision_app->pClientWin()->pStatusView()->AddItem (new StatusItem ( 0, "", @@ -633,9 +621,9 @@ vision_app->pClientWin()->pStatusView()->SetItemValue (STATUS_SERVER, fServerName.String(), false); vision_app->pClientWin()->pStatusView()->SetItemValue (STATUS_LAG, fMyLag.String(), false); vision_app->pClientWin()->pStatusView()->SetItemValue (STATUS_NICK, fMyNick.String(), true); - } + } break; - + default: ClientAgent::MessageReceived (msg); } @@ -663,7 +651,7 @@ convert_from_utf8 ( vision_app->GetInt32("encoding"), - outTemp.String(), + outTemp.String(), &length, convBuffer, &destLength, @@ -679,7 +667,7 @@ outTemp.RemoveLast ("\n"); ChannelMessage (outTemp.String(), nick); } - + } void MessageAgent::Parser (const char *buffer) @@ -709,13 +697,13 @@ convert_from_utf8 ( vision_app->GetInt32("encoding"), - outTemp.String(), + outTemp.String(), &length, convBuffer, &destLength, &state); - - + + if (send(fAcceptSocket, convBuffer, destLength, 0) < 0) { fDConnected = false; @@ -732,8 +720,8 @@ BString sBuffer (buffer); Display (sBuffer.String()); - + Display ("\n"); } Modified: branches/0.9.7/src/ParseENums.cpp =================================================================== --- branches/0.9.7/src/ParseENums.cpp 2013-05-31 01:34:17 UTC (rev 942) +++ branches/0.9.7/src/ParseENums.cpp 2013-06-04 23:48:57 UTC (rev 943) @@ -1,21 +1,21 @@ -/* - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is Vision. - * +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Vision. + * * The Initial Developer of the Original Code is The Vision Team. * Portions created by The Vision Team are * Copyright (C) 1999, 2000, 2001 The Vision Team. All Rights * Reserved. - * + * * Contributor(s): Wade Majors <wa...@ez...> * Rene Gollent * Todd Lair @@ -26,6 +26,7 @@ #include <Entry.h> #include <Menu.h> +#include <Notification.h> #include <Roster.h> #include "ClientWindow.h" @@ -45,16 +46,11 @@ #include <stdlib.h> #include <sys/socket.h> - -#ifdef USE_INFOPOPPER -#include <infopopper/InfoPopper.h> -#endif - bool ServerAgent::ParseENums (const char *data, const char *sWord) { int num (atoi (sWord)); - + switch (num) { case ZERO: // 0 @@ -62,12 +58,12 @@ // wasn't a numeric, or the server is playing tricks on us } return false; - + case ERR_UNKNOWNCOMMAND: // 421 - { + { BString tempString (RestOfString (data, 4)), badCmd (GetWord (data, 4)); - + if (badCmd == "VISION_LAG_CHECK") { int32 difference (system_time() - fLagCheck); @@ -81,18 +77,18 @@ fLagCount = 0; fCheckingLag = false; fMsgr.SendMessage (M_LAG_CHANGED); - } + } } else { tempString.RemoveFirst (":"); tempString.Append ("\n"); Display (tempString.String()); - } + } } return true; - - + + case RPL_WELCOME: // 001 case RPL_YOURHOST: // 002 case RPL_CREATED: // 003 @@ -103,7 +99,7 @@ fSMsgr.SendMessage (M_CONNECTED); fInitialMotd = true; fRetry = 0; - + if (fNetworkData.FindBool ("lagCheck")) { fMyLag = "0.000"; @@ -111,7 +107,7 @@ } BString theNick (GetWord (data, 3)); fMyNick = theNick; - + if (!IsHidden()) vision_app->pClientWin()->pStatusView()->SetItemValue (STATUS_NICK, theNick.String()); @@ -121,8 +117,8 @@ theMsg.Prepend ("* "); theMsg.Append ("\n"); Display (theMsg.String()); - - + + if (num == RPL_MYINFO) { // set "real" hostname @@ -133,10 +129,10 @@ hostName += fServerHostName.String(); hostName += "]"; fAgentWinItem->SetName (hostName.String()); - + // detect IRCd fIrcdtype = IRCD_STANDARD; - + if (theMsg.FindFirst("hybrid") > 0) fIrcdtype = IRCD_HYBRID; // ultimate and unreal share the same numerics, so treat them with the same @@ -153,40 +149,40 @@ fIrcdtype = IRCD_CONFERENCEROOM; else if (theMsg.FindFirst ("nn-") > 0) fIrcdtype = IRCD_NEWNET; - } + } } return true; - - + + case RPL_PROTOCTL: // 005 { // this numeric also serves as RPL_NNMAP on Newnet BString theMsg (RestOfString (data, 4)); theMsg.RemoveFirst (":"); - theMsg.Append ("\n"); - + theMsg.Append ("\n"); + switch (fIrcdtype) { case IRCD_NEWNET: { // RPL_NNMAP - Display (theMsg.String()); + Display (theMsg.String()); } break; - + default: { - // RPL_PROTOCTL + // RPL_PROTOCTL theMsg.Prepend ("* "); Display (theMsg.String()); } - } + } } return true; - - - + + + case RPL_LUSERHIGHESTCONN: // 250 case RPL_LUSERCLIENT: // 251 case RPL_LUSEROP: // 252 @@ -203,8 +199,8 @@ Display (theMsg.String()); } return true; - - + + /// strip and send to server agent /// case RPL_ULMAP: // 006 case RPL_ULMAPEND: // 007 @@ -301,20 +297,20 @@ Display (tempString.String()); } return true; - + case RPL_UMODEIS: // 221 { BString theMode (GetWord (data, 4)), tempString (S_PENUM_CURMODE); tempString += theMode; tempString += '\n'; - + BMessage msg (M_DISPLAY); PackDisplay (&msg, tempString.String(), C_WHOIS); PostActive (&msg); } return true; - + /// strip and send to active agent /// case RPL_TRYAGAIN: // 263 case RPL_UNAWAY: // 305 @@ -337,7 +333,7 @@ tempString += RestOfString (data, 4); tempString.RemoveFirst (":"); tempString.Append ("\n"); - + BMessage msg (M_DISPLAY); PackDisplay (&msg, tempString.String(), C_WHOIS, C_BACKGROUND, F_SERVER); PostActive (&msg); @@ -353,7 +349,7 @@ tempString += "Away: "; tempString += theReason; tempString += '\n'; - + if (fRemoteAwayMessages.find(theNick) != fRemoteAwayMessages.end()) { if (fRemoteAwayMessages[theNick] == theReason) @@ -367,7 +363,7 @@ PostActive (&msg); } return true; - + case RPL_USERHOST: // 302 { BString theHost (GetWord (data, 4)), @@ -378,7 +374,7 @@ tempString.RemoveFirst (":"); tempString.Append ("\n"); Display (tempString.String()); - + if (fGetLocalIP && (tempString.IFindFirst (fMyNick.String()) == 0)) { fGetLocalIP = false; @@ -409,18 +405,18 @@ } #endif } - + if (theHost != "-9z99" && theHost != "") { BMessage *dnsmsg (new BMessage); dnsmsg->AddString ("lookup", theHostname.String()); ClientAgent *client (ActiveClient()); - + if (client) dnsmsg->AddPointer("agent", client); else dnsmsg->AddPointer("agent", this); - + thread_id lookupThread = spawn_thread ( DNSLookup, "dns_lookup", @@ -429,19 +425,20 @@ resume_thread (lookupThread); } - } + } return true; - + case RPL_ISON: // 303 { BString nicks (RestOfString (data, 4)); - + BString onlined, offlined; + nicks.RemoveFirst (":"); - + int hasChanged (0); - + BMessage msg (M_NOTIFYLIST_UPDATE); - + for (int32 i = 0; i < fNotifyNicks.CountItems(); i++) { NotifyListItem *item (((NotifyListItem *)fNotifyNicks.ItemAt(i))); @@ -456,25 +453,10 @@ { item->SetState (true); hasChanged = 1; -#ifdef USE_INFOPOPPER - if (be_roster->IsRunning(InfoPopperAppSig) == true) { - entry_ref ref = vision_app->AppRef(); - BMessage infoMsg(InfoPopper::AddMessage); - infoMsg.AddString("appTitle", S_INFOPOPPER_TITLE); - infoMsg.AddString("title", fId.String()); - infoMsg.AddInt8("type", (int8)InfoPopper::Information); - - infoMsg.AddInt32("iconType", InfoPopper::Attribute); - infoMsg.AddRef("iconRef", &ref); - - BString content; - content << item->Text() << " is online"; - infoMsg.AddString("content", content); - - BMessenger(InfoPopperAppSig).SendMessage(&infoMsg); - }; -#endif + if (onlined.Length()) + onlined << ", "; + onlined << item->Text(); } } else @@ -483,27 +465,48 @@ { item->SetState (false); hasChanged = 2; -#ifdef USE_INFOPOPPER - if (be_roster->IsRunning(InfoPopperAppSig) == true) { - entry_ref ref = vision_app->AppRef(); - BMessage infoMsg(InfoPopper::AddMessage); - infoMsg.AddString("appTitle", S_INFOPOPPER_TITLE); - infoMsg.AddString("title", fId.String()); - infoMsg.AddInt8("type", (int8)InfoPopper::Information); - - infoMsg.AddInt32("iconType", InfoPopper::Attribute); - infoMsg.AddRef("iconRef", &ref); - - BString content; - content << item->Text() << " is offline"; - infoMsg.AddString("content", content); - - BMessenger(InfoPopperAppSig).SendMessage(&infoMsg); - }; -#endif + if (offlined.Length()) + offlined << ", "; + offlined << item->Text(); } } + + if (offlined.Length()) + { + BNotification notification(B_INFORMATION_NOTIFICATION); + notification.SetGroup(BString("Vision")); + entry_ref ref = vision_app->AppRef(); + notification.SetOnClickFile(&ref); + notification.SetTitle(fServerName.String()); + BString content; + content << offlined; + if (offlined.FindFirst(' ') > -1) + content << " are offline"; + else + content << " is offline"; + + notification.SetContent(content); + notification.Send(); + } + if (onlined.Length()) + { + BNotification notification(B_INFORMATION_NOTIFICATION); + notification.SetGroup(BString("Vision")); + entry_ref ref = vision_app->AppRef(); + notification.SetOnClickFile(&ref); + notification.SetTitle(fServerName.String()); + BString content; + content << onlined; + if (onlined.FindFirst(' ') > -1) + content << " are online"; + else + content << " is online"; + + notification.SetContent(content); + notification.Send(); + } + } fNotifyNicks.SortItems(SortNotifyItems); msg.AddPointer ("list", &fNotifyNicks); @@ -512,25 +515,25 @@ Window()->PostMessage (&msg); } return true; - + case RPL_WHOISIDENTIFIED: // 307 { BString theInfo (RestOfString (data, 5)); theInfo.RemoveFirst (":"); - + if (theInfo == "-9z99") { // USERIP reply? (RPL_U2USERIP) BString tempString (RestOfString (data, 4)); tempString.RemoveFirst (":"); tempString.Append ("\n"); - Display (tempString.String()); + Display (tempString.String()); return true; } - + BMessage display (M_DISPLAY); BString buffer; - + buffer += "[x] "; buffer += theInfo; buffer += "\n"; @@ -538,7 +541,7 @@ PostActive (&display); } return true; - + case RPL_WHOISADMIN: // 308 case RPL_WHOISSERVICESADMIN: // 309 case RPL_WHOISHELPOP: // 310 @@ -556,7 +559,7 @@ BMessage display (M_DISPLAY); BString buffer; - + buffer += "[x] "; buffer += theInfo; buffer += "\n"; @@ -564,7 +567,7 @@ PostActive (&display); } return true; - + case RPL_WHOISUSER: // 311 { BString theNick (GetWord (data, 4)), @@ -572,7 +575,7 @@ theAddress (GetWord (data, 6)), theName (RestOfString (data, 8)); theName.RemoveFirst (":"); - + BMessage display (M_DISPLAY); BString buffer; @@ -586,19 +589,19 @@ buffer += "[x] "; buffer += theName; buffer += "\n"; - + PackDisplay (&display, buffer.String(), C_WHOIS, C_BACKGROUND, F_SERVER); PostActive (&display); } return true; - + case RPL_WHOISSERVER: // 312 { BString theNick (GetWord (data, 4)), theServer (GetWord (data, 5)), theInfo (RestOfString (data, 6)); theInfo.RemoveFirst (":"); - + BMessage display (M_DISPLAY); BString buffer; @@ -611,7 +614,7 @@ PostActive (&display); } return true; - + case RPL_WHOWASUSER: // 314 { BString theNick (GetWord (data, 4)), @@ -632,7 +635,7 @@ PostActive (&msg); } return true; - + case RPL_WHOISIDLE: // 317 { BString theNick (GetWord (data, 4)), @@ -640,26 +643,26 @@ tempString2 ("[x] "), theTime (GetWord (data, 5)), signOnTime (GetWord (data, 6)); - + int64 idleTime (strtoul(theTime.String(), NULL, 0)); tempString += S_PENUM_IDLE; tempString += DurationString(idleTime * 1000 * 1000); tempString += "\n"; - + int32 serverTime = strtoul(signOnTime.String(), NULL, 0); - struct tm ptr; + struct tm ptr; time_t st; - char str[80]; - st = serverTime; + char str[80]; + st = serverTime; localtime_r (&st, &ptr); strftime (str,80,"%A %b %d %Y %I:%M %p %Z", &ptr); BString signOnTimeParsed (str); signOnTimeParsed.RemoveAll ("\n"); - + tempString2 += S_PENUM_SIGNON; tempString2 += signOnTimeParsed; tempString2 += "\n"; - + BMessage msg (M_DISPLAY); PackDisplay (&msg, tempString.String(), C_WHOIS, C_BACKGROUND, F_SERVER); PostActive (&msg); @@ -667,7 +670,7 @@ PostActive (&msg); } return true; - + case RPL_ENDOFWHOIS: // 318 case RPL_ENDOFNAMES: // 366 case RPL_ENDOFWHOWAS: // 369 @@ -675,7 +678,7 @@ // nothing } return true; - + case RPL_WHOISCHANNELS: // 319 { BString theChannels (RestOfString (data, 5)); @@ -691,7 +694,7 @@ PostActive (&display); } return true; - + case RPL_LISTSTART: // 321 { BMessage msg (M_LIST_BEGIN); @@ -699,7 +702,7 @@ vision_app->pClientWin()->DispatchMessage(&msg, (BView *)fListAgent); } return true; - + case RPL_LIST: // 322 { BMessage msg (M_LIST_EVENT); @@ -707,7 +710,7 @@ users (GetWord (data, 5)), topic (RestOfString (data, 6)); topic.RemoveFirst (":"); - + msg.AddString ("channel", channel.String()); msg.AddString ("users", users.String()); msg.AddString ("topic", topic.String()); @@ -715,8 +718,8 @@ if (fListAgent) vision_app->pClientWin()->DispatchMessage(&msg, (BView *)fListAgent); } - return true; - + return true; + case RPL_LISTEND: // 323 { BMessage msg (M_LIST_DONE); @@ -725,7 +728,7 @@ vision_app->pClientWin()->DispatchMessage(&msg, (BView *)fListAgent); } return true; - + case RPL_CHANNELMODEIS: // 324 { BString theChan (GetWord (data, 4)), @@ -738,15 +741,15 @@ theMode.Append(tempStuff); // avoid extra space w/o params } - ClientAgent *aClient (ActiveClient()), - *theClient (Client (theChan.String())); - + ClientAgent *aClient (ActiveClient()), + *theClient (Client (theChan.String())); + BString tempString(S_PENUM_CHANMODE); tempString += theChan; tempString += ": "; tempString += theMode; tempString += '\n'; - + BMessage msg (M_CHANNEL_MODES); msg.AddString ("msgz", tempString.String()); @@ -761,7 +764,7 @@ Display (tempString.String(), C_OP); } return true; - + case RPL_CHANNELMLOCK: // 325 { BString theChan (GetWord (data, 4)), @@ -771,9 +774,9 @@ lockMessage += ": "; lockMessage += mLock; lockMessage += "\n"; - + BMessage display (M_DISPLAY); - + PackDisplay (&display, lockMessage.String(), C_OP, C_BACKGROUND, F_TEXT); ClientAgent *theClient (Client (theChan.String())); if (theClient) @@ -782,23 +785,23 @@ fMsgr.SendMessage (&display); } return true; - + case RPL_CHANNELCREATED: // 329 { BString theChan (GetWord (data, 4)), theTime (GetWord (data, 5)), tempString; - + int32 serverTime (strtoul(theTime.String(), NULL, 0)); - struct tm ptr; + struct tm ptr; time_t st; - char str[80]; - st = serverTime; + char str[80]; + st = serverTime; localtime_r (&st, &ptr); strftime (str,80,"%a %b %d %Y %I:%M %p %Z",&ptr); BString theTimeParsed (str); theTimeParsed.RemoveAll ("\n"); - + tempString += theChan; tempString += " " S_PENUM_CHANCREATED " "; tempString += theTimeParsed; @@ -806,7 +809,7 @@ Display (tempString.String()); } return true; - + case RPL_NOTOPIC: // 331 { BString theChan (GetWord (data, 4)), @@ -819,7 +822,7 @@ PostActive (&msg); } return true; - + case RPL_TOPIC: // 332 { BString theChannel (GetWord (data, 4)), @@ -847,23 +850,23 @@ } } return true; - + case RPL_TOPICSET: // 333 { BString channel (GetWord (data, 4)), user (GetWord (data, 5)), theTime (GetWord (data, 6)); - + int32 serverTime (strtoul(theTime.String(), NULL, 0)); - struct tm ptr; + struct tm ptr; time_t st; - char str[80]; - st = serverTime; + char str[80]; + st = serverTime; localtime_r (&st, &ptr); strftime (str,80,"%A %b %d %Y %I:%M %p %Z",&ptr); BString theTimeParsed (str); theTimeParsed.RemoveAll ("\n"); - + ClientAgent *client (Client (channel.String())); if (client) @@ -882,27 +885,27 @@ } } return true; - + case RPL_INVITING: // 341 { BString channel (GetWord (data, 5)), theNick (GetWord (data, 4)), tempString; - + tempString += "*** "; tempString += theNick; tempString += S_PENUM_INVITING; tempString += channel; tempString += ".\n"; - + BMessage display (M_DISPLAY); - + PackDisplay (&display, tempString.Str... [truncated message content] |