void jView::Draw(BRect update) { DBG(AWT_EVT, printf( "jView::Draw(" )); DBG(AWT_EVT, update.PrintToStream()); DBG(AWT_EVT, printf( "\n" )); #if 0 DBG(AWT_EVT, printf("Draw\n")); // !!! NOT THE BEST PLACE, // it would be better to intercept events before they are dispatched to the handlers // (see event_hook) BMessage * msg = new BMessage(); msg->what = UPDATE_EVENT; /* custom update event */ msg->AddPointer(sourceTag, Window()); msg->AddRect("frame", Frame()); /* update the entire frame */ bigtime_t t = system_time(); msg->AddInt64("when", t); update.PrintToStream(); javaApp->AddMessage( msg ); #endif }
status_t ZKWindow::SaveSettings (void) { PRINT(("ZKWindow::SaveSettings()\n")); status_t status; BMessage settings; BPath path; BFile file; // add settings to message settings.AddRect("winframe", Frame()); // get path to settings-file if ((status = find_directory(B_USER_SETTINGS_DIRECTORY, & path)) != B_OK) return status; if ((status = path.SetTo(path.Path(),"Kirilla/ZooKeeper/settings")) != B_OK) return status; if ((status = file.SetTo(path.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE)) != B_OK) return status; if ((status = settings.Flatten(& file)) != B_OK) return status; return B_OK; }
status_t InspectorWindow::SaveSettings(BMessage& settings) { AutoLocker<BLooper> lock(this); if (!lock.IsLocked()) return B_ERROR; settings.MakeEmpty(); status_t error = settings.AddRect("frame", Frame()); if (error != B_OK) return error; error = _SaveMenuFieldMode(fHexMode, "Hex", settings); if (error != B_OK) return error; error = _SaveMenuFieldMode(fEndianMode, "Endian", settings); if (error != B_OK) return error; error = _SaveMenuFieldMode(fTextMode, "Text", settings); if (error != B_OK) return error; return B_OK; }
void TMagnify::CopyImage() { StartSave(); be_clipboard->Lock(); be_clipboard->Clear(); BMessage *message = be_clipboard->Data(); if (!message) { printf(B_TRANSLATE_CONTEXT("no clip msg\n", "In console, when clipboard is empty after clicking Copy image")); return; } BMessage *embeddedBitmap = new BMessage(); (fImageView->Bitmap())->Archive(embeddedBitmap,false); status_t err = message->AddMessage(kBitmapMimeType, embeddedBitmap); if (err == B_OK) err = message->AddRect("rect", fImageView->Bitmap()->Bounds()); if (err == B_OK) be_clipboard->Commit(); be_clipboard->Unlock(); EndSave(); }
void stub_source_run(je_source_plugin *cookie) { source_private *data = (source_private *)cookie->data; BMessage drawBitmap(JE_DRAW_BITMAP); BMessage msg; msg.what = JE_FRAMERATE_CHANGED; msg.AddInt64("framerate", 33000); msg.AddInt32("which", data->id); data->graphics_pipeline->SendMessage(&msg); msg.RemoveName("framerate"); msg.what = JE_FRAME_SIZE_CHANGED; msg.AddRect("rect", data->outSize); data->graphics_pipeline->SendMessage(&msg); msg.RemoveName("rect"); msg.what = JE_SOURCE_READY; data->graphics_pipeline->SendMessage(&msg); while (1) { data->nextFrame = system_time() + 33000; snooze_until(data->nextFrame, B_SYSTEM_TIMEBASE); if (data->exit) break; drawBitmap.RemoveName("bitmap"); drawBitmap.AddPointer("bitmap", data->frame); data->window->SendMessage(&drawBitmap); } // it's ok to kill us now release_sem(data->exitSem); }
BMessage* Resize::Do(PDocument *doc, BMessage *settings) { BMessage *undoMessage = new BMessage(); BList *selected = doc->GetSelected(); BList *changed = doc->GetChangedNodes(); float dx,dy; BRect *newFrame = new BRect(0,0,100,100); BRect *oldFrame = new BRect(0,0,100,100); BMessage *node = new BMessage(); int32 i = 0; if ( (settings->FindFloat("dx",&dx)==B_OK) && (settings->FindFloat("dy",&dy)==B_OK) ) { for (i=0;i<selected->CountItems();i++) { node=(BMessage *)selected->ItemAt(i); node->FindRect("Node::frame",oldFrame); undoMessage->AddRect("oldFrame",*oldFrame); undoMessage->AddPointer("node",node); *newFrame = *oldFrame; newFrame->right += dx; newFrame->bottom += dy; if ( (newFrame->IsValid()) && (newFrame->Width()>20) && ((newFrame->Height()>20)) ) { node->ReplaceRect("Node::frame",*newFrame); changed->AddItem(node); } } } doc->SetModified(); settings->RemoveName("Resize::Undo"); settings->AddMessage("Resize::Undo",undoMessage); settings= PCommand::Do(doc,settings); return settings; }
bool MainWindow::QuitRequested() { BMessage msg; msg.AddRect("pos", Frame()); UpdatePreferences("main_window", msg); return be_app->PostMessage(B_QUIT_REQUESTED); }
void MainWindow::StoreSettings(BMessage& settings) const { settings.AddRect("window frame", Frame()); BMessage columnSettings; fPackageListView->SaveState(&columnSettings); settings.AddMessage("column settings", &columnSettings); }
void NSBrowserFrameView::Draw(BRect updateRect) { BMessage *message = NULL; //message = Window()->DetachCurrentMessage(); // might be called directly... if (message == NULL) message = new BMessage(_UPDATE_); message->AddRect("rect", updateRect); nsbeos_pipe_message(message, this, fGuiWindow); }
/*! \brief Requests an update of the specified rectangle \param rect The area to update, in the parent's coordinates This could be considered equivalent to BView::Invalidate() */ void ServerWindow::RequestDraw(BRect rect) { //STRACE(("ServerWindow %s: Request Draw\n",fTitle.String())); BMessage msg; msg.what = _UPDATE_; msg.AddRect("_rect", rect); // TODO: implement this function //SendMessageToClient(&msg); }
void MainWindow::StoreSettings(BMessage& settings) const { settings.AddRect("window frame", Frame()); BMessage columnSettings; fPackageListView->SaveState(&columnSettings); settings.AddMessage("column settings", &columnSettings); settings.AddBool("show develop packages", fModel.ShowDevelopPackages()); settings.AddBool("show source packages", fModel.ShowSourcePackages()); }
void MainWindow::StoreSettings(BMessage& settings) const { settings.AddRect(_WindowFrameName(), Frame()); if (!fSinglePackageMode) { settings.AddRect("window frame", Frame()); BMessage columnSettings; fPackageListView->SaveState(&columnSettings); settings.AddMessage("column settings", &columnSettings); settings.AddBool("show featured packages", fModel.ShowFeaturedPackages()); settings.AddBool("show available packages", fModel.ShowAvailablePackages()); settings.AddBool("show installed packages", fModel.ShowInstalledPackages()); settings.AddBool("show develop packages", fModel.ShowDevelopPackages()); settings.AddBool("show source packages", fModel.ShowSourcePackages()); } settings.AddString("username", fModel.Username()); }
HWindow::~HWindow() { delete fFilePanel; delete fPlayer; BPath path; BMessage msg; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { path.Append(kSettingsFile); BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE); if (file.InitCheck() == B_OK) { msg.AddRect("frame", fFrame); msg.Flatten(&file); } } }
// Saves the application settings file to (saveEntry). Because this is a // non-essential file, errors are ignored when writing the settings. void ShortcutsWindow::_SaveWindowSettings(BEntry& saveEntry) { BFile saveTo(&saveEntry, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); if (saveTo.InitCheck() != B_OK) return; BMessage saveMsg; saveMsg.AddRect("window frame", Frame()); for (int i = 0; i < fColumnListView->CountColumns(); i++) { CLVColumn* column = fColumnListView->ColumnAt(i); saveMsg.AddFloat("column width", column->Width()); } saveMsg.Flatten(&saveTo); }
void Settings::Save(BFile* file) { BMessage message; // store application settings for (int i = 0; i < AppSettingsCount(); i++) { AppSettings* app = AppSettingsAt(i); message.AddString("message", app->GetMimeType()); message.AddString("p", app->GetPrinter()); } // store printer settings for (int i = 0; i < PrinterSettingsCount(); i++) { PrinterSettings* p = PrinterSettingsAt(i); message.AddString("P", p->GetPrinter()); message.AddMessage("S", p->GetPageSettings()); message.AddMessage("J", p->GetJobSettings()); } message.AddBool("UseConfigWindow", fUseConfigWindow); message.AddRect("ConfigWindowFrame", fConfigWindowFrame); message.AddString("DefaultPrinter", fDefaultPrinter); message.Flatten(file); }
status_t TermWindow::_SaveWindowPosition() { BFile file; BMessage originalSettings; // Read the settings file if it exists and is a valid BMessage. status_t status = _GetWindowPositionFile(&file, B_READ_ONLY); if (status == B_OK) { status = originalSettings.Unflatten(&file); file.Unset(); if (status != B_OK) status = originalSettings.MakeEmpty(); if (status != B_OK) return status; } // Replace the settings int32 id = fTerminalRoster.ID(); BRect rect(Frame()); if (originalSettings.ReplaceRect("rect", id, rect) != B_OK) originalSettings.AddRect("rect", rect); int32 workspaces = Workspaces(); if (originalSettings.ReplaceInt32("workspaces", id, workspaces) != B_OK) originalSettings.AddInt32("workspaces", workspaces); // Resave the whole thing status = _GetWindowPositionFile (&file, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); if (status != B_OK) return status; return originalSettings.Flatten(&file); }
status_t Converter::CreateNode(BMessage *nodeS,BMessage *connectionS,TiXmlElement *parent,int32 level, int32 thisLine) { TiXmlNode *node; BMessage *pDocNode = new BMessage(P_C_CLASS_TYPE); BMessage *data = new BMessage(); BMessage *pattern = new BMessage(); int32 line = 0; for( node = parent->FirstChild("node"); node;) { CreateConnection(connectionS, parent,node->ToElement()); CreateNode(nodeS,connectionS, node->ToElement(),level+1, line); line++; node = node->NextSibling(); } if (parent->Attribute("TEXT")) data->AddString("Name",parent->Attribute("TEXT")); else data->AddString("Name","Unnamed"); if (parent->Attribute("ID")) { const char *idString = parent->Attribute("ID"); int32 id = GetID(idString); pDocNode->AddPointer("this",(void *)id); } if (parent->Attribute("CREATED")) pDocNode->AddInt32("Node::created",atoi(parent->Attribute("CREATED"))); if (parent->Attribute("MODIFIED")) pDocNode->AddInt32("Node::modified",atoi(parent->Attribute("MODIFIED"))); if (parent->Attribute("BACKGROUND_COLOR")) pattern->AddInt32("FillColor",GetRGB(parent->Attribute("BACKGROUND_COLOR"))); if (parent->Attribute("COLOR")) pattern->AddInt32("BorderColor",GetRGB(parent->Attribute("COLOR"))); //find all Attributes for (node = parent->FirstChild("arrowlink"); node;) { CreateConnection(connectionS,parent,node->ToElement()); node = node->NextSibling(); } pDocNode->AddMessage("Node::Data",data); pDocNode->AddMessage("Node::Pattern",pattern); BRect *nodeRect = new BRect(100,100,200,150); if (pDocNode->FindRect("Node::frame",nodeRect) != B_OK) { int32 left, top, right, bottom; if (level == 0) { left = X_START; top = Y_START; } else { if (parent->Attribute("POSITION")) { if (strcmp(parent->Attribute("POSITION"),"left") != 0) left = (level*(NODE_WIDTH+10))+X_START; else left = X_START-(level*(NODE_WIDTH+10)); } top = (thisLine*(NODE_HEIGHT+10))+ 10; } right = left + NODE_WIDTH; bottom = top + NODE_HEIGHT; nodeRect->Set(left,top, right, bottom); pDocNode->AddRect("Node::frame",*nodeRect); } nodeS->AddMessage("node",pDocNode); }
status_t TeamWindow::SaveSettings(GuiTeamUiSettings* settings) { AutoLocker<BWindow> lock(this); if (!lock.IsLocked()) return B_ERROR; BMessage inspectorSettings; if (fUiSettings.Settings("inspectorWindow", inspectorSettings) == B_OK) { if (!settings->AddSettings("inspectorWindow", inspectorSettings)) return B_NO_MEMORY; } BMessage archive; BMessage teamWindowSettings; if (teamWindowSettings.AddRect("frame", Frame()) != B_OK) return B_NO_MEMORY; if (GuiSettingsUtils::ArchiveSplitView(archive, fSourceSplitView) != B_OK) return B_NO_MEMORY; if (teamWindowSettings.AddMessage("sourceSplit", &archive) != B_OK) return B_NO_MEMORY; if (GuiSettingsUtils::ArchiveSplitView(archive, fFunctionSplitView) != B_OK) return B_NO_MEMORY; if (teamWindowSettings.AddMessage("functionSplit", &archive) != B_OK) return B_NO_MEMORY; if (GuiSettingsUtils::ArchiveSplitView(archive, fImageSplitView) != B_OK) return B_NO_MEMORY; if (teamWindowSettings.AddMessage("imageSplit", &archive)) return B_NO_MEMORY; if (GuiSettingsUtils::ArchiveSplitView(archive, fThreadSplitView) != B_OK) return B_NO_MEMORY; if (teamWindowSettings.AddMessage("threadSplit", &archive)) return B_NO_MEMORY; if (GuiSettingsUtils::ArchiveSplitView(archive, fConsoleSplitView) != B_OK) return B_NO_MEMORY; if (teamWindowSettings.AddMessage("consoleSplit", &archive)) return B_NO_MEMORY; if (fImageListView->SaveSettings(archive) != B_OK) return B_NO_MEMORY; if (teamWindowSettings.AddMessage("imageListView", &archive)) return B_NO_MEMORY; if (fImageFunctionsView->SaveSettings(archive) != B_OK) return B_NO_MEMORY; if (teamWindowSettings.AddMessage("imageFunctionsView", &archive)) return B_NO_MEMORY; if (fThreadListView->SaveSettings(archive) != B_OK) return B_NO_MEMORY; if (teamWindowSettings.AddMessage("threadListView", &archive)) return B_NO_MEMORY; if (fVariablesView->SaveSettings(archive) != B_OK) return B_NO_MEMORY; if (teamWindowSettings.AddMessage("variablesView", &archive)) return B_NO_MEMORY; if (fRegistersView->SaveSettings(archive) != B_OK) return B_NO_MEMORY; if (teamWindowSettings.AddMessage("registersView", &archive)) return B_NO_MEMORY; if (fStackTraceView->SaveSettings(archive) != B_OK) return B_NO_MEMORY; if (teamWindowSettings.AddMessage("stackTraceView", &archive)) return B_NO_MEMORY; if (fBreakpointsView->SaveSettings(archive) != B_OK) return B_NO_MEMORY; if (teamWindowSettings.AddMessage("breakpointsView", &archive)) return B_NO_MEMORY; if (fConsoleOutputView->SaveSettings(archive) != B_OK) return B_NO_MEMORY; if (teamWindowSettings.AddMessage("consoleOutputView", &archive)) return B_NO_MEMORY; if (!settings->AddSettings("teamWindow", teamWindowSettings)) return B_NO_MEMORY; return B_OK; }
bool ClientWindow::ParseCmd (const char *data) { BString firstWord (GetWord(data, 1).ToUpper()); if (firstWord == "/WALLOPS" // we need to insert a ':' before parm2 || firstWord == "/SQUIT" // for the user || firstWord == "/PRIVMSG") { BString theCmd (firstWord.RemoveAll ("/")), theRest (RestOfString (data, 2)); BMessage send (M_SERVER_SEND); AddSend (&send, theCmd); if (theRest != "-9z99") { AddSend (&send, " :"); AddSend (&send, theRest); } AddSend (&send, endl); return true; } if (firstWord == "/KILL") // we need to insert a ':' before parm3 { // for the user BString theCmd (firstWord.RemoveAll ("/")), theTarget (GetWord (data, 2)), theRest (RestOfString (data, 3)); BMessage send (M_SERVER_SEND); AddSend (&send, theCmd); AddSend (&send, " "); AddSend (&send, theTarget); if (theRest != "-9z99") { AddSend (&send, " :"); AddSend (&send, theRest); } AddSend (&send, endl); return true; } // some quick aliases for scripts, these will of course be // moved to an aliases section eventually if (firstWord == "/SOUNDPLAY" || firstWord == "/CL-AMP") { app_info ai; be_app->GetAppInfo (&ai); BEntry entry (&ai.ref); BPath path; entry.GetPath (&path); path.GetParent (&path); //path.Append ("data"); path.Append ("scripts"); if (firstWord == "/SOUNDPLAY") path.Append ("soundplay-hey"); else path.Append ("cl-amp-clr"); BMessage *msg (new BMessage); msg->AddString ("exec", path.Path()); msg->AddPointer ("client", this); thread_id execThread = spawn_thread ( ExecPipe, "exec_thread", B_LOW_PRIORITY, msg); resume_thread (execThread); return true; } if (firstWord == "/ABOUT") { be_app_messenger.SendMessage (B_ABOUT_REQUESTED); return true; } if (firstWord == "/AWAY") { BString theReason (RestOfString (data, 2)); BString tempString; if (theReason != "-9z99") { //nothing to do } else { theReason = "BRB"; // Todo: make a default away msg option } const char *expansions[1]; expansions[0] = theReason.String(); tempString = ExpandKeyed (bowser_app->GetCommand (CMD_AWAY).String(), "R", expansions); tempString.RemoveFirst("\n"); BMessage send (M_SERVER_SEND); AddSend (&send, "AWAY"); AddSend (&send, " :"); AddSend (&send, theReason.String()); AddSend (&send, endl); if (id != serverName) { ActionMessage (tempString.String(), myNick.String()); } return true; } if (firstWord == "/BACK") { BMessage send (M_SERVER_SEND); AddSend (&send, "AWAY"); AddSend (&send, endl); if (id != serverName) { ActionMessage ( bowser_app->GetCommand (CMD_BACK).String(), myNick.String()); } return true; } if (firstWord == "/CHANSERV" || firstWord == "/NICKSERV" || firstWord == "/MEMOSERV") { BString theCmd (firstWord.RemoveFirst ("/")), theRest (RestOfString (data, 2)); theCmd.ToLower(); if (theRest != "-9z99") { if (bowser_app->GetMessageOpenState()) { BMessage msg (OPEN_MWINDOW); BMessage buffer (M_SUBMIT); buffer.AddString ("input", theRest.String()); msg.AddMessage ("msg", &buffer); msg.AddString ("nick", theCmd.String()); sMsgr.SendMessage (&msg); } else { BString tempString; tempString << "[M]-> " << theCmd << " > " << theRest << "\n"; Display (tempString.String(), 0); BMessage send (M_SERVER_SEND); AddSend (&send, "PRIVMSG "); AddSend (&send, theCmd); AddSend (&send, " :"); AddSend (&send, theRest); AddSend (&send, endl); } } return true; } if (firstWord == "/CLEAR") { text->ClearView (false); return true; } if (firstWord == "/FCLEAR") { text->ClearView (true); return true; } if (firstWord == "/CTCP") { BString theTarget (GetWord (data, 2)); BString theAction (RestOfString (data, 3)); if (theAction != "-9z99") { theAction.ToUpper(); if (theAction.ICompare ("PING") == 0) { time_t now (time (0)); theAction << " " << now; } CTCPAction (theTarget, theAction); BMessage send (M_SERVER_SEND); AddSend (&send, "PRIVMSG "); AddSend (&send, theTarget << " :\1" << theAction << "\1"); AddSend (&send, endl); } return true; } if (firstWord == "/DCC") { BString secondWord (GetWord (data, 2)); BString theNick (GetWord (data, 3)); BString theFile (RestOfString(data, 4)); if (secondWord.ICompare ("SEND") == 0 && theNick != "-9z99") { BMessage *msg (new BMessage (CHOSE_FILE)); msg->AddString ("nick", theNick.String()); if (theFile != "-9z99") { char filePath[B_PATH_NAME_LENGTH] = "\0"; if (theFile.ByteAt(0) != '/') { find_directory(B_USER_DIRECTORY, 0, false, filePath, B_PATH_NAME_LENGTH); filePath[strlen(filePath)] = '/'; } strcat(filePath, theFile.LockBuffer(0)); theFile.UnlockBuffer(); // use BPath to resolve relative pathnames, above code forces it // to use /boot/home as a working dir as opposed to the app path BPath sendPath(filePath, NULL, true); // the BFile is used to verify if the file exists // based off the documentation get_ref_for_path *should* // return something other than B_OK if the file doesn't exist // but that doesn't seem to be working correctly BFile sendFile(sendPath.Path(), B_READ_ONLY); // if the file exists, send, otherwise drop to the file panel if (sendFile.InitCheck() == B_OK) { sendFile.Unset(); entry_ref ref; get_ref_for_path(sendPath.Path(), &ref); msg->AddRef("refs", &ref); sMsgr.SendMessage(msg); return true; } } BFilePanel *myPanel (new BFilePanel); BString myTitle ("Sending a file to "); myTitle.Append (theNick); myPanel->Window()->SetTitle (myTitle.String()); myPanel->SetMessage (msg); myPanel->SetButtonLabel (B_DEFAULT_BUTTON, "Send"); myPanel->SetTarget (sMsgr); myPanel->Show(); } else if (secondWord.ICompare ("CHAT") == 0 && theNick != "-9z99") { BMessage msg (CHAT_ACTION); msg.AddString ("nick", theNick.String()); sMsgr.SendMessage (&msg); } return true; } if (firstWord == "/DOP" || firstWord == "/DEOP") { BString theNick (RestOfString (data, 2)); if (theNick != "-9z99") { BMessage send (M_SERVER_SEND); AddSend (&send, "MODE "); AddSend (&send, id); AddSend (&send, " -oooo "); AddSend (&send, theNick); AddSend (&send, endl); } return true; } if (firstWord == "/DESCRIBE") { BString theTarget (GetWord (data, 2)); BString theAction (RestOfString (data, 3)); if (theAction != "-9z99") { BMessage send (M_SERVER_SEND); AddSend (&send, "PRIVMSG "); AddSend (&send, theTarget); AddSend (&send, " :\1ACTION "); AddSend (&send, theAction); AddSend (&send, "\1"); AddSend (&send, endl); BString theActionMessage ("[ACTION]-> "); theActionMessage << theTarget << " -> " << theAction << "\n"; Display (theActionMessage.String(), 0); } return true; } if (firstWord == "/DNS") { BString parms (GetWord(data, 2)); ChannelWindow *window; MessageWindow *message; if ((window = dynamic_cast<ChannelWindow *>(this))) { int32 count (window->namesList->CountItems()); for (int32 i = 0; i < count; ++i) { NameItem *item ((NameItem *)(window->namesList->ItemAt (i))); if (!item->Name().ICompare (parms.String(), strlen (parms.String()))) //nick { BMessage send (M_SERVER_SEND); AddSend (&send, "USERHOST "); AddSend (&send, item->Name().String()); AddSend (&send, endl); PostMessage(&send); return true; } } } else if ((message = dynamic_cast<MessageWindow *>(this))) { BString eid (id); eid.RemoveLast (" [DCC]"); if (!ICompare(eid, parms) || !ICompare(myNick, parms)) { BMessage send (M_SERVER_SEND); AddSend (&send, "USERHOST "); AddSend (&send, parms.String()); AddSend (&send, endl); PostMessage(&send); return true; } } if (parms != "-9z99") { BMessage *msg (new BMessage); msg->AddString ("lookup", parms.String()); msg->AddPointer ("client", this); thread_id lookupThread = spawn_thread ( DNSLookup, "dns_lookup", B_LOW_PRIORITY, msg); resume_thread (lookupThread); } return true; } if (firstWord == "/PEXEC") // piped exec { BString theCmd (RestOfString (data, 2)); if (theCmd != "-9z99") { BMessage *msg (new BMessage); msg->AddString ("exec", theCmd.String()); msg->AddPointer ("client", this); thread_id execThread = spawn_thread ( ExecPipe, "exec_thread", B_LOW_PRIORITY, msg); resume_thread (execThread); } return true; } if (firstWord == "/EXCLUDE") { BString second (GetWord (data, 2)), rest (RestOfString (data, 3)); if (rest != "-9z99" && rest != "-9z99") { BMessage msg (M_EXCLUDE_COMMAND); msg.AddString ("second", second.String()); msg.AddString ("cmd", rest.String()); msg.AddString ("server", serverName.String()); msg.AddRect ("frame", Frame()); bowser_app->PostMessage (&msg); } return true; } if (firstWord == "/IGNORE") { BString rest (RestOfString (data, 2)); if (rest != "-9z99") { BMessage msg (M_IGNORE_COMMAND); msg.AddString ("cmd", rest.String()); msg.AddString ("server", serverName.String()); msg.AddRect ("frame", Frame()); bowser_app->PostMessage (&msg); } return true; } if (firstWord == "/INVITE" || firstWord == "/I") { BString theUser (GetWord (data, 2)); if (theUser != "-9z99") { BString theChan (GetWord (data, 3)); if (theChan == "-9z99") theChan = id; BMessage send (M_SERVER_SEND); AddSend (&send, "INVITE "); AddSend (&send, theUser << " " << theChan); AddSend (&send, endl); } return true; } if (firstWord == "/JOIN" || firstWord == "/J") { BString channel (GetWord (data, 2)); if (channel != "-9z99") { if (channel[0] != '#' && channel[0] != '&') channel.Prepend("#"); BMessage send (M_SERVER_SEND); AddSend (&send, "JOIN "); AddSend (&send, channel); BString key (GetWord (data, 3)); if (key != "-9z99") { AddSend (&send, " "); AddSend (&send, key); } AddSend (&send, endl); } return true; } if (firstWord == "/KICK" || firstWord == "/K") { BString theNick (GetWord (data, 2)); if (theNick != "-9z99") { BString theReason (RestOfString (data, 3)); if (theReason == "-9z99") { // No expansions theReason = bowser_app ->GetCommand (CMD_KICK); } BMessage send (M_SERVER_SEND); AddSend (&send, "KICK "); AddSend (&send, id); AddSend (&send, " "); AddSend (&send, theNick); AddSend (&send, " :"); AddSend (&send, theReason); AddSend (&send, endl); } return true; } if (firstWord == "/LIST") { BMessage msg (M_LIST_COMMAND); msg.AddString ("cmd", data); msg.AddString ("server", serverName.String()); msg.AddRect ("frame", Frame()); bowser_app->PostMessage (&msg); return true; } if (firstWord == "/M") { BString theMode (RestOfString (data, 2)); BMessage send (M_SERVER_SEND); AddSend (&send, "MODE "); if (id == serverName) AddSend (&send, myNick); else if (id[0] == '#' || id[0] == '&') AddSend (&send, id); else AddSend (&send, myNick); if (theMode != "-9z99") { AddSend (&send, " "); AddSend (&send, theMode); } AddSend (&send, endl); return true; } if (firstWord == "/ME") { BString theAction (RestOfString (data, 2)); if (theAction != "-9z99") { ActionMessage (theAction.String(), myNick.String()); } return true; } if (firstWord == "/MODE") { BString theMode (RestOfString (data, 3)); BString theTarget (GetWord (data, 2)); if (theTarget != "-9z99") { BMessage send (M_SERVER_SEND); AddSend (&send, "MODE "); if (theMode == "-9z99") AddSend (&send, theTarget); else AddSend (&send, theTarget << " " << theMode); AddSend (&send, endl); } return true; } if (firstWord == "/MSG") { BString theRest (RestOfString (data, 3)); BString theNick (GetWord (data, 2)); if (theRest != "-9z99" && myNick.ICompare (theNick)) { if (bowser_app->GetMessageOpenState()) { BMessage msg (OPEN_MWINDOW); BMessage buffer (M_SUBMIT); buffer.AddString ("input", theRest.String()); msg.AddMessage ("msg", &buffer); msg.AddString ("nick", theNick.String()); sMsgr.SendMessage (&msg); } else { BString tempString; tempString << "[M]-> " << theNick << " > " << theRest << "\n"; Display (tempString.String(), 0); BMessage send (M_SERVER_SEND); AddSend (&send, "PRIVMSG "); AddSend (&send, theNick); AddSend (&send, " :"); AddSend (&send, theRest); AddSend (&send, endl); } } return true; } if (firstWord == "/NICK") { BString newNick (GetWord (data, 2)); if (newNick != "-9z99") { BString tempString ("*** Trying new nick "); tempString << newNick << ".\n"; Display (tempString.String(), 0); BMessage send (M_SERVER_SEND); AddSend (&send, "NICK "); AddSend (&send, newNick); AddSend (&send, endl); } return true; } if (firstWord == "/NOTICE") { BString theTarget (GetWord (data, 2)); BString theMsg (RestOfString (data, 3)); if (theMsg != "-9z99") { BMessage send (M_SERVER_SEND); AddSend (&send, "NOTICE "); AddSend (&send, theTarget); AddSend (&send, " :"); AddSend (&send, theMsg); AddSend (&send, endl); BString tempString ("[N]-> "); tempString << theTarget << " -> " << theMsg << '\n'; Display (tempString.String(), 0); } return true; } if (firstWord == "/NOTIFY") { BString rest (RestOfString (data, 2)); if (rest != "-9z99") { BMessage msg (M_NOTIFY_COMMAND); msg.AddString ("cmd", rest.String()); msg.AddBool ("add", true); msg.AddString ("server", serverName.String()); msg.AddRect ("frame", Frame()); bowser_app->PostMessage (&msg); } return true; } if (firstWord == "/OP") { BString theNick (RestOfString (data, 2)); if (theNick != "-9z99") { // TODO only applies to a channel BMessage send (M_SERVER_SEND); AddSend (&send, "MODE "); AddSend (&send, id); AddSend (&send, " +oooo "); AddSend (&send, theNick); AddSend (&send, endl); } return true; } if (firstWord == "/PART") { BMessage msg (B_QUIT_REQUESTED); msg.AddBool ("bowser:part", true); PostMessage (&msg); return true; } if (firstWord == "/PING") { BString theNick (GetWord (data, 2)); if (theNick != "-9z99") { long theTime (time (0)); BString tempString ("/CTCP "); tempString << theNick << " PING " << theTime; SlashParser (tempString.String()); } return true; } if (firstWord == "/PREFERENCES") { be_app_messenger.SendMessage (M_PREFS_BUTTON); return true; } if (firstWord == "/QUERY" || firstWord == "/Q") { BString theNick (GetWord (data, 2)); if (theNick != "-9z99") { BMessage msg (OPEN_MWINDOW); msg.AddString ("nick", theNick.String()); sMsgr.SendMessage (&msg); } return true; } if (firstWord == "/QUIT") { BString theRest (RestOfString (data, 2)); BString buffer; if (theRest == "-9z99") { const char *expansions[1]; BString version (bowser_app->BowserVersion()); expansions[0] = version.String(); theRest = ExpandKeyed (bowser_app ->GetCommand (CMD_QUIT).String(), "V", expansions); } buffer << "QUIT :" << theRest; BMessage msg (B_QUIT_REQUESTED); msg.AddString ("bowser:quit", buffer.String()); sMsgr.SendMessage (&msg); return true; } if (firstWord == "/RAW" || firstWord == "/QUOTE") { BString theRaw (RestOfString (data, 2)); if (theRaw != "-9z99") { BMessage send (M_SERVER_SEND); AddSend (&send, theRaw); AddSend (&send, endl); BString tempString ("[R]-> "); tempString << theRaw << '\n'; Display (tempString.String(), 0); } return true; } if (firstWord == "/RECONNECT") { BMessage msg (M_SLASH_RECONNECT); msg.AddString ("server", serverName.String()); bowser_app->PostMessage (&msg); return true; } if (firstWord == "/SLEEP") { BString rest (RestOfString (data, 2)); if (rest != "-9z99") { // this basically locks up the window its run from, // but I can't think of a better way with our current // commands implementation int32 time = atoi(rest.String()); snooze(time * 1000 * 100); // deciseconds? 10 = one second } return true; } if (firstWord == "/TOPIC" || firstWord == "/T") { BString theChan (id); BString theTopic (RestOfString (data, 2)); BMessage send (M_SERVER_SEND); AddSend (&send, "TOPIC "); if (theTopic == "-9z99") AddSend (&send, theChan); else AddSend (&send, theChan << " :" << theTopic); AddSend (&send, endl); return true; } if (firstWord == "/UNIGNORE") { BString rest (RestOfString (data, 2)); if (rest != "-9z99") { BMessage msg (M_UNIGNORE_COMMAND); msg.AddString ("cmd", rest.String()); msg.AddString ("server", serverName.String()); msg.AddRect ("frame", Frame()); bowser_app->PostMessage (&msg); } return true; } if (firstWord == "/UNNOTIFY") { BString rest (RestOfString (data, 2)); if (rest != "-9z99") { BMessage msg (M_NOTIFY_COMMAND); msg.AddString ("cmd", rest.String()); msg.AddBool ("add", false); msg.AddRect ("frame", Frame()); msg.AddString ("server", serverName.String()); bowser_app->PostMessage (&msg); } return true; } if (firstWord == "/UPTIME") { BString parms (GetWord(data, 2)); BString uptime (DurationString(system_time())); BString expandedString; const char *expansions[1]; expansions[0] = uptime.String(); expandedString = ExpandKeyed (bowser_app->GetCommand (CMD_UPTIME).String(), "U", expansions); expandedString.RemoveFirst("\n"); if ((id != serverName) && (parms == "-9z99")) { BMessage send (M_SERVER_SEND); AddSend (&send, "PRIVMSG "); AddSend (&send, id); AddSend (&send, " :"); AddSend (&send, expandedString.String()); AddSend (&send, endl); ChannelMessage (expandedString.String(), myNick.String()); } else if ((parms == "-l") || (id == serverName)) // echo locally { BString tempString; tempString << "Uptime: " << expandedString << "\n"; Display (tempString.String(), &whoisColor); } return true; } if (firstWord == "/VERSION" || firstWord == "/TIME") { BString theCmd (firstWord.RemoveFirst ("/")), theNick (GetWord (data, 2)); theCmd.ToUpper(); // the "." check is because the user might specify a server name if (theNick != "-9z99" && theNick.FindFirst(".") < 0) { BString tempString ("/CTCP "); tempString << theNick << " " << theCmd; SlashParser (tempString.String()); } else { BMessage send (M_SERVER_SEND); AddSend (&send, theCmd); if (theNick != "-9z99") { AddSend (&send, " "); AddSend (&send, theNick); } AddSend (&send, endl); } return true; } if (firstWord == "/VISIT") { BString buffer (data); int32 place; if ((place = buffer.FindFirst (" ")) >= 0) { buffer.Remove (0, place + 1); const char *arguments[] = {buffer.String(), 0}; be_roster->Launch ( "text/html", 1, const_cast<char **>(arguments)); } return true; } if (firstWord != "" && firstWord[0] == '/') // != "" is required to prevent a nasty crash with string[0] { BString theCmd (firstWord.RemoveAll ("/")), theRest (RestOfString (data, 2)); BMessage send (M_SERVER_SEND); if (theCmd == "W") theCmd = "WHOIS"; AddSend (&send, theCmd); if (theRest != "-9z99") { AddSend (&send, " "); AddSend (&send, theRest); } AddSend (&send, endl); return true; } return false; // we couldn't handle this message }