unsigned char DataFile::GetHash(BString text) //////////////////////////////////////////////////////////////////////// { unsigned char result = 0; text.ToUpper(); for (int i=0; i<text.Length(); i++) result ^= text.ByteAt(i); return result; }
status_t perform_edit(MTextAddOn *addon) { status_t result = B_OK; entry_ref headerFile; BPoint where(0,0); if (addon->Window() && addon->Window()->Lock()) { uint32 buttons; addon->Window()->ChildAt(0)->GetMouse(&where, &buttons); addon->Window()->ChildAt(0)->ConvertToScreen(&where); addon->Window()->Unlock(); where += BPoint(-3,-3); } result = addon->GetRef(headerFile); BString fileName; if (result >= B_OK) fileName = headerFile.name; CLanguageInterface *languageInterface = NULL; if (addon->Window()) { PDoc *doc = dynamic_cast<PDoc *>(addon->Window()); if (doc && doc->TextView()) { int lang = doc->TextView()->Language(); if (lang > -1) languageInterface = CLanguageInterface::FindIntf(lang); } } BString header; result = RunPopUpMenu(where, header, fileName, languageInterface); //printf("result %s\n", strerror(result)); if (result == B_CANCELED) return B_OK; if (result < B_OK) return result; #if 0 // Do not change the case if a shift key was pressed if ((modifiers() & B_SHIFT_KEY) == 0) fileName.ToUpper(); #endif addon->Select(0, 0); addon->Insert(header.String()); return result; }
void BootPromptWindow::_InitCatalog(bool saveSettings) { // Initilialize the Locale Kit // TODO: The below code is a work-around for not being able to // call GetAppCatalog() more than once. be_catalog = be_app_catalog = NULL; // NOTE: be_catalog and be_app_catalog will point fo &fCatalog! be_locale->GetAppCatalog(&fCatalog); // Generate a settings file // TODO: This should not be necessary. // be_locale_roster->SetPreferredLanguages() should take care of things if (!saveSettings) return; BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK || path.Append("Locale settings") != B_OK) { return; } BMessage settings; BFile file; if (file.SetTo(path.Path(), B_READ_ONLY) == B_OK) settings.Unflatten(&file); BString language; if (fCatalog.GetLanguage(&language) == B_OK) { settings.RemoveName("language"); settings.AddString("language", language.String()); } settings.RemoveName("country"); BCountry country(language.String(), language.ToUpper()); settings.AddString("country", country.Code()); if (file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY) != B_OK || settings.Flatten(&file) != B_OK) { fprintf(stderr, "Failed to write Local Kit settings!\n"); } }
/* isCue * checks if selected file is a cue file (checks by file extension) * if yes, returns true */ bool ProjectTypeSelector::isCue() { BString *SelectedFile = (BString*)FileList->FirstItem(); BString SelectedFileTMP; BString FileExtension; BString tmp; //get file extension SelectedFile->CopyInto(SelectedFileTMP, 0, (int)SelectedFile->Length()); SelectedFileTMP.RemoveAll("/"); for(int i = 3; i > 0; i--) { tmp.SetTo(SelectedFileTMP.ByteAt((SelectedFileTMP.Length() - i)), 1); FileExtension.Insert(tmp.String(), FileExtension.Length()); } FileExtension.ToUpper(); if(FileExtension.Compare("CUE") == 0) return true; return false; }
bool DataFile::GetBool(BString key, bool &result) //////////////////////////////////////////////////////////////////////// { BString temp; if (GetEntry(key, temp)) { temp.ToUpper(); if (temp == "TRUE") { result = true; return true; } else if (temp == "FALSE") { result = false; return true; } return false; // nem true es nem is false -> error es akkor default marad } else return false; }
// CreateNewProject - create all the text files for the new project void NewProjectWindow::CreateNewProject(void) { // Set Project Name and Various other settings char tmp[300]; // this will be removed when all references are gone char cmd[256]; int x; // this will be removed when all references are gone FILE *f; // this will be removed when all references are gone char FileName[256]; char AppName[256]; // this will be removed when all references are gone BString FileContents; BString UpperProjectName; ProjectName.SetTo(txtNewProject->Text()); UpperProjectName.SetTo(ProjectName.String()); UpperProjectName.ToUpper(); sprintf(AppName,"%s",ProjectName.String()); // this will be removed when all references are gone // 1) Get Current Directory app_info daInfo; be_app->GetAppInfo(&daInfo); BEntry daEntry(&daInfo.ref); daEntry.GetParent(&daEntry); BPath pPath(&daEntry); char apath[256]; ::memcpy(apath, pPath.Path(), 256); // 2) Create New Directory sprintf(cmd,"mkdir %s/projects/%s",apath,ProjectName.String()); system(cmd); // 3) Create Basic Files for a Default App // Application Header sprintf(FileName,"%s/projects/%s/%s.h",apath,ProjectName.String(),ProjectName.String()); FileContents.SetTo("#ifndef __"); FileContents.Append(UpperProjectName.String()); FileContents.Append("_H__\n"); FileContents.Append("#define __"); FileContents.Append(UpperProjectName.String()); FileContents.Append("_H__\n\n"); FileContents.Append("extern const char *APP_SIGNATURE;\n\n"); FileContents.Append("class "); FileContents.Append(ProjectName.String()); FileContents.Append(" : public BApplication\n{\n\tpublic:\n\t\t"); FileContents.Append(ProjectName.String()); FileContents.Append("();\n"); FileContents.Append("\t\tvirtual void MessageReceived(BMessage *message);\n"); FileContents.Append("\tprivate:\n\n};\n\n"); FileContents.Append("#endif\n"); CreateFile(FileName,"Header",FileContents); // Application Constants.h sprintf(FileName,"%s/projects/%s/%sConstants.h",apath,ProjectName.String(),ProjectName.String()); FileContents.SetTo("#ifndef __"); FileContents.Append(UpperProjectName.String()); FileContents.Append("CONSTANTS_H__\n"); FileContents.Append("#define __"); FileContents.Append(UpperProjectName.String()); FileContents.Append("CONSTANTS_H__\n\n"); FileContents.Append("// Pointers to BWindows\n"); FileContents.Append("extern "); FileContents.Append(ProjectName.String()); FileContents.Append("Window* ptr"); FileContents.Append(ProjectName.String()); FileContents.Append("Window;\n\n"); FileContents.Append("// Product Name and Properties\n"); FileContents.Append("const char projtitle[]=\""); FileContents.Append(ProjectName.String()); FileContents.Append("\";\nconst char projversion[]=\"v0.1\";\nconst char projauthor[]=\""); FileContents.Append(txtAuthor->Text()); FileContents.Append("\";\n\n"); FileContents.Append("#endif\n"); CreateFile(FileName,"Constants",FileContents); // Windows Header sprintf(FileName,"%s/projects/%s/%sWindows.h",apath,ProjectName.String(),ProjectName.String()); FileContents.SetTo("#ifndef __"); FileContents.Append(UpperProjectName.String()); FileContents.Append("WINDOWS_H__\n"); FileContents.Append("#define __"); FileContents.Append(UpperProjectName.String()); FileContents.Append("WINDOWS_H__\n\n"); FileContents.Append("#include \""); FileContents.Append(ProjectName.String()); FileContents.Append(".h\"\n"); FileContents.Append("#include \""); FileContents.Append(ProjectName.String()); FileContents.Append("Views.h\"\n\n"); FileContents.Append("class "); FileContents.Append(ProjectName.String()); FileContents.Append("View;\n\n"); FileContents.Append("class "); FileContents.Append(ProjectName.String()); FileContents.Append("Window : public BWindow\n"); FileContents.Append("{\n\tpublic:\n\t\t"); FileContents.Append(ProjectName.String()); FileContents.Append("Window(BRect frame);\n"); FileContents.Append("\t\t~"); FileContents.Append(ProjectName.String()); FileContents.Append("Window();\n"); FileContents.Append("\t\tvirtual bool QuitRequested();\n"); FileContents.Append("\t\tvirtual void MessageReceived(BMessage *message);\n"); FileContents.Append("\tprivate:\n"); FileContents.Append("\t\tvoid InitWindow(void);\n\n"); if (chkLoadSavePrefs->Value() == B_CONTROL_ON) { FileContents.Append("\t\tvoid LoadSettings(BMessage *msg);\n"); FileContents.Append("\t\tvoid SaveSettings(void);\n"); } FileContents.Append("\t\t"); FileContents.Append(ProjectName.String()); FileContents.Append("View*\t\tptr"); FileContents.Append(ProjectName.String()); FileContents.Append("View;\n"); FileContents.Append("};\n\n"); FileContents.Append("#endif\n"); CreateFile(FileName,"Windows Header",FileContents); // FileContents.Append(""); // f = fopen(FileName,"w"); // x = fputs("/*\n\n",f); // sprintf(tmp,"%s Windows Header\n\n",ProjectName.String()); // x = fputs(tmp,f); // sprintf(tmp,"Author: %s\n\n",txtAuthor->Text()); // x = fputs(tmp,f); // x = fputs("(C)2003 Created using BRIE (http://brie.sf.net/)\n\n",f); // x = fputs("*/\n\n",f); // sprintf(tmp,"#ifndef __%sWINDOWS_H__\n",ProjectName.String()); // x = fputs(tmp,f); // sprintf(tmp,"#define __%sWINDOWS_H__\n\n",ProjectName.String()); // x = fputs(tmp,f); // sprintf(tmp,"#include \"%s.h\"\n",ProjectName.String()); // x = fputs(tmp,f); // sprintf(tmp,"#include \"%sViews.h\"\n\n",ProjectName.String()); // x = fputs(tmp,f); // sprintf(tmp,"class %sView;\n\n",ProjectName.String()); // x = fputs(tmp,f); // sprintf(tmp,"class %sWindow : public BWindow\n",ProjectName.String()); // x = fputs(tmp,f); // x = fputs("{\n",f); // x = fputs("\tpublic:\n",f); // sprintf(tmp,"\t\t%sWindow(BRect frame);\n",ProjectName.String()); // x = fputs(tmp,f); // sprintf(tmp,"\t\t~%sWindow();\n",ProjectName.String()); // x = fputs(tmp,f); // x = fputs("\t\tvirtual bool QuitRequested();\n",f); // x = fputs("\t\tvirtual void MessageReceived(BMessage *message);\n",f); // x = fputs("\tprivate:\n",f); // x = fputs("\t\tvoid InitWindow(void);\n\n",f); // add load/save pref (if checked) // if (chkLoadSavePrefs->Value() == B_CONTROL_ON) { // x = fputs("\t\tvoid LoadSettings(BMessage *msg);\n",f); // x = fputs("\t\tvoid SaveSettings(void); \n",f); // } // sprintf(tmp,"\t\t%sView*\t\tptr%sView;\n",ProjectName.String(),ProjectName.String()); // x = fputs(tmp,f); // x = fputs("};\n\n",f); // x = fputs("#endif\n",f); // fclose(f); // Views Header sprintf(FileName,"%s/projects/%s/%sViews.h",apath,ProjectName.String(),ProjectName.String()); f = fopen(FileName,"w"); x = fputs("/*\n\n",f); sprintf(tmp,"%s Views Header\n\n",ProjectName.String()); x = fputs(tmp,f); sprintf(tmp,"Author: %s\n\n",txtAuthor->Text()); x = fputs(tmp,f); x = fputs("(C)2003 Created using BRIE (http://brie.sf.net/)\n\n",f); x = fputs("*/\n\n",f); sprintf(tmp,"#ifndef __%sVIEWS_H__\n",AppName); x = fputs(tmp,f); sprintf(tmp,"#define __%sVIEWS_H__\n\n",AppName); x = fputs(tmp,f); sprintf(tmp,"#include \"%s.h\"\n",AppName); x = fputs(tmp,f); sprintf(tmp,"#include \"%sWindows.h\"\n\n",AppName); x = fputs(tmp,f); sprintf(tmp,"class %sView : public BView\n",AppName); x = fputs(tmp,f); x = fputs("{\n",f); x = fputs("\tpublic:\n",f); sprintf(tmp,"\t\t%sView(BRect frame);\n",AppName); x = fputs(tmp,f); x = fputs("\t\tvirtual void Draw(BRect updateRect);\n",f); x = fputs("};\n\n",f); x = fputs("#endif\n",f); fclose(f); // View CPP sprintf(FileName,"%s/projects/%s/%sView.cpp",apath,AppName,AppName); f = fopen(FileName,"w"); x = fputs("/*\n\n",f); sprintf(tmp,"%s View\n\n",AppName); x = fputs(tmp,f); sprintf(tmp,"Author: %s\n\n",txtAuthor->Text()); x = fputs(tmp,f); x = fputs("(C)2003 Created using BRIE (http://brie.sf.net/)\n\n",f); x = fputs("*/\n\n",f); x = fputs("// Includes ------------------------------------------------------------------------------------------ //\n",f); x = fputs("#include <Alert.h>\n",f); x = fputs("#include <Application.h>\n",f); x = fputs("#include <Screen.h>\n",f); x = fputs("#include <stdio.h>\n",f); x = fputs("#include <Window.h>\n",f); x = fputs("#include <View.h>\n\n",f); sprintf(tmp,"#include \"%sWindows.h\"\n",AppName); x = fputs(tmp,f); sprintf(tmp,"#include \"%sViews.h\"\n",AppName); x = fputs(tmp,f); x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f); sprintf(tmp,"// %sView - Constructor\n",AppName); x = fputs(tmp,f); sprintf(tmp,"%sView::%sView (BRect frame) : BView (frame, \"%sView\", B_FOLLOW_ALL_SIDES, B_WILL_DRAW )\n",AppName,AppName,AppName); x = fputs(tmp,f); x = fputs("{\n",f); x = fputs("\tSetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));\n",f); x = fputs("}\n",f); x = fputs("// ------------------------------------------------------------------------------------------------- //\n\n",f); sprintf(tmp,"void %sView::Draw(BRect /*updateRect*/)\n",AppName); x = fputs(tmp,f); x = fputs("{\n",f); x = fputs("\tBRect r;\n",f); x = fputs("\tr = Bounds();\n",f); x = fputs("}\n",f); x = fputs("// ------------------------------------------------------------------------------------------------- //\n",f); fclose(f); // Main CPP sprintf(FileName,"%s/projects/%s/%s.cpp",apath,AppName,AppName); f = fopen(FileName,"w"); x = fputs("/*\n\n",f); sprintf(tmp,"%s\n\n",AppName); x = fputs(tmp,f); sprintf(tmp,"Author: %s\n\n",txtAuthor->Text()); x = fputs(tmp,f); x = fputs("(C)2003 Created using BRIE (http://brie.sf.net/)\n\n",f); x = fputs("*/\n\n",f); x = fputs("// Includes ------------------------------------------------------------------------------------------ //\n",f); x = fputs("#include <Alert.h>\n",f); x = fputs("#include <Application.h>\n",f); x = fputs("#include <Button.h>\n",f); x = fputs("#include <Entry.h>\n",f); x = fputs("#include <File.h>\n",f); x = fputs("#include <FilePanel.h>\n",f); x = fputs("#include <ListView.h>\n",f); x = fputs("#include <Path.h>\n",f); x = fputs("#include <Screen.h>\n",f); x = fputs("#include <ScrollView.h>\n",f); x = fputs("#include <stdio.h>\n",f); x = fputs("#include <string.h>\n",f); x = fputs("#include <TextControl.h>\n",f); x = fputs("#include <Window.h>\n",f); x = fputs("#include <View.h>\n\n",f); sprintf(tmp,"#include \"%s.h\"\n",AppName); x = fputs(tmp,f); sprintf(tmp,"#include \"%sWindows.h\"\n",AppName); x = fputs(tmp,f); sprintf(tmp,"#include \"%sViews.h\"\n",AppName); x = fputs(tmp,f); sprintf(tmp,"#include \"%sConstants.h\"\n",AppName); x = fputs(tmp,f); //x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f); x = fputs("// Constants ---------------------------------------------------------------------------------------- //\n\n",f); sprintf(tmp,"const char *APP_SIGNATURE = \"application/x-vnd.%s.%s\"; // Application Signature and Title\n\n",txtAuthor->Text(),AppName); x = fputs(tmp,f); x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f); sprintf(tmp,"%sWindow\t\t*ptr%sWindow;\n\n",AppName,AppName); x = fputs(tmp,f); sprintf(tmp,"// %s - Constructor\n",AppName); x = fputs(tmp,f); sprintf(tmp,"%s::%s() : BApplication (APP_SIGNATURE)\n",AppName,AppName); x = fputs(tmp,f); x = fputs("{\n",f); x = fputs("\t// Default Window Size - Position doesn't matter as we centre the form to the current screen size\n",f); x = fputs("\tBRect screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());\n\n",f); x = fputs("\tfloat FormTopDefault = 0;\n",f); x = fputs("\tfloat FormLeftDefault = 0;\n",f); x = fputs("\tfloat FormWidthDefault = screenFrame.Width() - 500;\n",f); x = fputs("\tfloat FormHeightDefault = screenFrame.Height() - 500;\n",f); sprintf(tmp,"\tBRect %sWindowRect(FormTopDefault,FormLeftDefault,FormLeftDefault+FormWidthDefault,FormTopDefault+FormHeightDefault);\n\n",AppName); x = fputs(tmp,f); sprintf(tmp,"\tptr%sWindow = new %sWindow(%sWindowRect);\n",AppName,AppName,AppName); x = fputs(tmp,f); x = fputs("}\n",f); x = fputs("// ------------------------------------------------------------------------------------------------- //\n\n",f); sprintf(tmp,"// %s::MessageReceived -- handles incoming messages\n",AppName); x = fputs(tmp,f); sprintf(tmp,"void %s::MessageReceived (BMessage *message)\n",AppName); x = fputs(tmp,f); x = fputs("{\n",f); x = fputs("\tswitch(message->what)\n",f); x = fputs("\t{\n",f); x = fputs("\t\tdefault:\n",f); x = fputs("\t\t\tBApplication::MessageReceived(message); // pass it along ... \n",f); x = fputs("\t\t\tbreak;\n",f); x = fputs("\t}\n",f); x = fputs("}\n",f); x = fputs("// ------------------------------------------------------------------------------------------------- //\n\n",f); sprintf(tmp,"// %s Main\n",AppName); x = fputs(tmp,f); x = fputs("int main(void)\n",f); x = fputs("{\n",f); sprintf(tmp,"\t%s theApp;\n",AppName); x = fputs(tmp,f); x = fputs("\ttheApp.Run();\n",f); x = fputs("\treturn 0;\n",f); x = fputs("}\n",f); x = fputs("// end --------------------------------------------------------------------------------------------- //\n\n",f); fclose(f); // Window CPP sprintf(FileName,"%s/projects/%s/%sWindow.cpp",apath,AppName,AppName); f = fopen(FileName,"w"); x = fputs("/*\n\n",f); sprintf(tmp,"%sWindow\n\n",AppName); x = fputs(tmp,f); sprintf(tmp,"Author: %s\n\n",txtAuthor->Text()); x = fputs(tmp,f); x = fputs("(C)2003 Created using BRIE (http://brie.sf.net/)\n\n",f); x = fputs("*/\n\n",f); x = fputs("// Includes ------------------------------------------------------------------------------------------ //\n",f); x = fputs("#include <Alert.h>\n",f); x = fputs("#include <Application.h>\n",f); x = fputs("#include <Button.h>\n",f); // add load/save pref (if checked) if (chkLoadSavePrefs->Value() == B_CONTROL_ON) { x = fputs("#include <File.h>\n",f); x = fputs("#include <FindDirectory.h>\n",f); } // add menubar includes (if checked) if (chkMenuBar->Value() == B_CONTROL_ON) { x = fputs("#include <MenuBar.h>\n",f); x = fputs("#include <Menu.h>\n",f); x = fputs("#include <MenuItem.h>\n",f); } x = fputs("#include <Path.h>\n",f); x = fputs("#include <Screen.h>\n",f); x = fputs("#include <ScrollView.h>\n",f); x = fputs("#include <stdio.h>\n",f); x = fputs("#include <string.h>\n",f); x = fputs("#include <TextControl.h>\n",f); x = fputs("#include <Window.h>\n",f); x = fputs("#include <View.h>\n\n",f); sprintf(tmp,"#include \"%s.h\"\n",AppName); x = fputs(tmp,f); sprintf(tmp,"#include \"%sWindows.h\"\n",AppName); x = fputs(tmp,f); sprintf(tmp,"#include \"%sViews.h\"\n",AppName); x = fputs(tmp,f); x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f); x = fputs("// CenterWindowOnScreen -- Centers the BWindow to the Current Screen\n",f); x = fputs("static void CenterWindowOnScreen(BWindow* w)\n",f); x = fputs("{\n",f); x = fputs("\tBRect\tscreenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());",f); x = fputs("\tBPoint\tpt;\n",f); x = fputs("\tpt.x = screenFrame.Width()/2 - w->Bounds().Width()/2;\n",f); x = fputs("\tpt.y = screenFrame.Height()/2 - w->Bounds().Height()/2;\n\n",f); x = fputs("\tif (screenFrame.Contains(pt))\n",f); x = fputs("\t\tw->MoveTo(pt);\n",f); x = fputs("}\n",f); x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f); sprintf(tmp,"// %sWindow - Constructor\n",AppName); x = fputs(tmp,f); sprintf(tmp,"%sWindow::%sWindow(BRect frame) : BWindow (frame, \"%s v0.1\", B_TITLED_WINDOW, B_NORMAL_WINDOW_FEEL , 0)\n",AppName,AppName,AppName); x = fputs(tmp,f); x = fputs("{\n",f); x = fputs("\tInitWindow();\n",f); x = fputs("\tCenterWindowOnScreen(this);\n",f); // add load/save pref (if checked) if (chkLoadSavePrefs->Value() == B_CONTROL_ON) { x = fputs("\n",f); x = fputs("\t// Load User Settings \n",f); x = fputs("\tBPath path;\n",f); x = fputs("\tfind_directory(B_USER_SETTINGS_DIRECTORY,&path);\n",f); sprintf(tmp,"\tpath.Append(\"%s_Settings\",true);\n",AppName); x = fputs(tmp,f); x = fputs("\tBFile file(path.Path(),B_READ_ONLY);\n",f); x = fputs("\tBMessage msg;\n",f); x = fputs("\tmsg.Unflatten(&file);\n",f); x = fputs("\tLoadSettings (&msg);\n",f); x = fputs("\n",f); } x = fputs("\tShow();\n",f); x = fputs("}\n",f); x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f); sprintf(tmp,"// %sWindow - Destructor\n",AppName); x = fputs(tmp,f); sprintf(tmp,"%sWindow::~%sWindow()\n",AppName,AppName); x = fputs(tmp,f); x = fputs("{\n",f); x = fputs("\texit(0);\n",f); x = fputs("}\n",f); x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f); sprintf(tmp,"// %sWindow::InitWindow -- Initialization Commands here\n",AppName); x = fputs(tmp,f); sprintf(tmp,"void %sWindow::InitWindow(void)\n",AppName); x = fputs(tmp,f); x = fputs("{\n",f); x = fputs("\tBRect r;\n",f); x = fputs("\tr = Bounds(); // the whole view\n",f); // add MenuBar (if checked) if (chkMenuBar->Value() == B_CONTROL_ON) { ptrMenuCreator = new MenuCreator(BRect(367.0, 268.0, 657.0, 500.0)); x = fputs("\n",f); x = fputs("\t// MenuBar - Created by BRIE Menu Creator\n",f); x = fputs("\tBMenu *menu;\n",f); x = fputs("\tBRect rMenuBar;\n\n",f); x = fputs("\trMenuBar = Bounds();\n",f); x = fputs("\trMenuBar.top = 20;\n\n",f); x = fputs("\t// Add the menu bar\n",f); x = fputs("\trMenuBar.top = 0;\n",f); x = fputs("\trMenuBar.bottom = 19;\n",f); x = fputs("\tmenubar = new BMenuBar(rMenuBar, \"menu_bar\");\n",f); x = fputs("\tAddChild(menubar);\n",f); x = fputs("\n",f); x = fputs("\t// ### INSERT MENU HERE FROM MENU CREATOR ### \n",f); x = fputs("\n",f); x = fputs("\t// EndMenuBar (please do not remove this line)\n\n",f); } x = fputs("\t// Create the Views\n",f); sprintf(tmp,"\tAddChild(ptr%sView = new %sView(r));\n",AppName,AppName); x = fputs(tmp,f); x = fputs("}\n",f); x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f); sprintf(tmp,"// %sWindow::QuitRequested -- Post a message to the app to quit\n",AppName); x = fputs(tmp,f); sprintf(tmp,"bool %sWindow::QuitRequested()\n",AppName); x = fputs(tmp,f); x = fputs("{\n",f); if (chkLoadSavePrefs->Value() == B_CONTROL_ON) { x = fputs("\tSaveSettings();\n",f); } x = fputs("\tbe_app->PostMessage(B_QUIT_REQUESTED);\n",f); x = fputs("\treturn true;\n",f); x = fputs("}\n",f); x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f); // add load/save pref (if checked) if (chkLoadSavePrefs->Value() == B_CONTROL_ON) { sprintf(tmp,"// %sWindow::LoadSettings -- Loads your current settings\n",AppName); x = fputs(tmp,f); sprintf(tmp,"void %sWindow::LoadSettings(BMessage *msg)\n",AppName); x = fputs(tmp,f); x = fputs("{\n",f); x = fputs("\tBRect frame;\n\n",f); x = fputs("\tif (B_OK == msg->FindRect(\"windowframe\",&frame)) {\n",f); x = fputs("\t\tMoveTo(frame.left,frame.top);\n",f); x = fputs("\t\tResizeTo(frame.right-frame.left,frame.bottom-frame.top);\n",f); x = fputs("\t}\n",f); x = fputs("}\n",f); x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f); sprintf(tmp,"// %sWindow::SaveSettings -- Saves the Users settings\n",AppName); x = fputs(tmp,f); sprintf(tmp,"void %sWindow::SaveSettings(void)\n",AppName); x = fputs(tmp,f); x = fputs("{\n",f); x = fputs("\tBMessage msg;\n",f); x = fputs("\tmsg.AddRect(\"windowframe\",Frame());\n\n",f); x = fputs("\tBPath path;\n",f); x = fputs("\tstatus_t result = find_directory(B_USER_SETTINGS_DIRECTORY,&path);\n",f); x = fputs("\tif (result == B_OK) {\n",f); sprintf(tmp,"\t\tpath.Append(\"%s_Settings\",true);\n",AppName); x = fputs(tmp,f); x = fputs("\t\tBFile file(path.Path(),B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);\n",f); x = fputs("\t\tmsg.Flatten(&file);\n",f); x = fputs("\t}\n",f); x = fputs("}\n",f); x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f); } sprintf(tmp,"// %sWindow::MessageReceived -- receives messages\n",AppName); x = fputs(tmp,f); sprintf(tmp,"void %sWindow::MessageReceived (BMessage *message)\n",AppName); x = fputs(tmp,f); x = fputs("{\n",f); x = fputs("\tswitch(message->what)\n",f); x = fputs("\t{\n",f); x = fputs("\t\tdefault:\n",f); x = fputs("\t\t\tBWindow::MessageReceived(message);\n",f); x = fputs("\t\t\tbreak;\n",f); x = fputs("\t}\n",f); x = fputs("}\n",f); x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f); fclose(f); // this step doesnt work - would be nice if rsrc files could be made from text // 4) Copy newproject.rsrc to our project folder //sprintf(cmd,"cp %s/newproject.rsrc %s/projects/%s/",apath,apath,AppName); //system(cmd); //sprintf(cmd,"mv %s/projects/%s/newproject.rsrc %s/projects/%s/%s.rsrc",apath,AppName,apath,AppName,AppName); //system(cmd); // 5) Create BRIE Project File - this is required for internal use in this application only sprintf(FileName,"%s/projects/%s.bprj",apath,AppName); f = fopen(FileName,"w"); sprintf(tmp,"## BRIE Project File for %s ##\n",AppName); x = fputs(tmp,f); sprintf(tmp,"ProjectName=%s\n",AppName); x = fputs(tmp,f); sprintf(tmp,"ProjectDir=%s/projects/%s\n",apath,AppName); x = fputs(tmp,f); sprintf(tmp,"Author=%s\n",txtAuthor->Text()); x = fputs(tmp,f); sprintf(tmp,"Language=%s\n","C/C++"); // might change later ... x = fputs(tmp,f); x = fputs("### Files\n",f); sprintf(tmp,"%s.cpp\n",AppName); x = fputs(tmp,f); sprintf(tmp,"%sWindow.cpp\n",AppName); x = fputs(tmp,f); sprintf(tmp,"%sView.cpp\n",AppName); x = fputs(tmp,f); fclose(f); sprintf(tmp,"%s.bprj",AppName); //ptrFileWindow->SetProject(FileName,tmp); //ptrProjectWindow->SetProjectTitle(AppName); //msg = new BMessage(SET_PROJECT_NAME); //msg.AddString("ProjectName",AppName); //msg.AddBool("NotSaved",true); //ptrProjectWindow->PostMessage(&msg); // Create our ProjectFiles BMessage BMessage pfmsg(ADD_PROJECT_FILE); BString ProgName; ProgName.SetTo(AppName); ProgName.Append(".cpp"); pfmsg.AddString(kProjectFile, ProgName.String()); BMessenger(ptrProjectWindow).SendMessage(&pfmsg); pfmsg.MakeEmpty(); ProgName.SetTo(AppName); ProgName.Append("Window.cpp"); pfmsg.AddString(kProjectFile, ProgName.String()); BMessenger(ptrProjectWindow).SendMessage(&pfmsg); pfmsg.MakeEmpty(); ProgName.SetTo(AppName); ProgName.Append("View.cpp"); pfmsg.AddString(kProjectFile, ProgName.String()); BMessenger(ptrProjectWindow).SendMessage(&pfmsg); // 6) Create makefile for compilation sprintf(FileName,"%s/projects/%s/makefile",apath,AppName); f = fopen(FileName,"w"); sprintf(tmp,"## BeOS Makefile for %s ##\n",AppName); x = fputs(tmp,f); sprintf(tmp,"## Author: %s\n",txtAuthor->Text()); x = fputs(tmp,f); x = fputs("## Created by BRIE (http://brie.sf.net/)\n\n",f); x = fputs("## Application Specific Settings ---------------------------------------------\n\n",f); x = fputs("# specify the name of the binary\n",f); sprintf(tmp,"NAME= %s\n",AppName); x = fputs(tmp,f); x = fputs("# specify the type of binary\n",f); x = fputs("# APP: Application\n",f); x = fputs("# SHARED: Shared library or add-on\n",f); x = fputs("# STATIC: Static library archive\n",f); x = fputs("# DRIVER: Kernel Driver\n",f); x = fputs("TYPE= APP\n\n",f); x = fputs("# specify the source files to use\n",f); x = fputs("# Note that spaces in folder names do not work well with this makefile.\n",f); sprintf(tmp,"SRCS= %s.cpp %sWindow.cpp %sView.cpp\n",AppName,AppName,AppName); x = fputs(tmp,f); x = fputs("# end of srcs\n\n",f); x = fputs("# specify the resource files to use\n",f); //x = fputs("RSRCS= ../../newproject.rsrc\n\n",f); x = fputs("RSRCS= \n\n",f); x = fputs("# specify additional libraries to link against\n",f); x = fputs("LIBS= be root\n\n",f); x = fputs("# specify additional paths to directories \n",f); x = fputs("LIBPATHS=\n\n",f); x = fputs("# additional paths to look for system headers\n",f); x = fputs("SYSTEM_INCLUDE_PATHS =\n\n",f); x = fputs("# additional paths to look for local headers\n",f); x = fputs("LOCAL_INCLUDE_PATHS =\n\n",f); x = fputs("# specify the level of optimization that you desire - NONE, SOME, FULL\n",f); x = fputs("OPTIMIZE=\n\n",f); x = fputs("# specify any preprocessor symbols to be defined. \n",f); x = fputs("DEFINES=\n\n",f); x = fputs("# specify special warning levels - NONE, ALL\n",f); x = fputs("WARNINGS = ALL\n\n",f); x = fputs("# specify whether image symbols will be created\n",f); x = fputs("SYMBOLS = TRUE\n\n",f); x = fputs("# specify debug settings\n",f); x = fputs("DEBUGGER =\n\n",f); x = fputs("# specify additional compiler flags for all files\n",f); x = fputs("COMPILER_FLAGS =\n\n",f); x = fputs("# specify additional linker flags\n",f); x = fputs("LINKER_FLAGS =\n\n",f); x = fputs("## include the makefile-engine\n",f); x = fputs("DEVEL_DIRECTORY := \\\n",f); x = fputs("\t$(shell findpaths -r \"makefile_engine\" B_FIND_PATH_DEVELOP_DIRECTORY)",f); x = fputs("include $(DEVEL_DIRECTORY)/etc/makefile-engine",f); fclose(f); // 7) Send Messages to other Windows to update BMessage msg(SET_PROJECT_TITLE); msg.AddString(kProjectName, AppName); //msg.AddBool(kNotSaved, true); // make this false later - true for debug purposes BMessenger(ptrFileWindow).SendMessage(&msg); BMessenger(ptrProjectWindow).SendMessage(&msg); ProjectName.SetTo(AppName); ProjectPath = apath; // set properties window to show current Window from New Project ptrPropertiesWindow->ShowProperties("Window",ProjectName.String()); // 8) Show Tracker and/or Continue ShowTracker(apath,AppName); }
void GetExtension(const BString &name, BString &string) { int i = name.Length(); while ((i >= 0) && (name[i] != '.')) i--; if (i >= 0) string = BString(&name.String()[i+1]); string.ToUpper(); }
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 }