RuleFilter::RuleFilter(MailProtocol& protocol, AddonSettings* addonSettings) : MailFilter(protocol, addonSettings) { const BMessage* settings = &addonSettings->Settings(); // attribute is adapted to our "capitalize-each-word-in-the-header" policy settings->FindString("attribute", &fAttribute); fAttribute.CapitalizeEachWord(); BString regex; settings->FindString("regex", ®ex); int32 index = regex.FindFirst("REGEX:"); if (index == B_ERROR || index > 0) EscapeRegexTokens(regex); else regex.RemoveFirst("REGEX:"); fMatcher.SetPattern(regex, false); settings->FindString("argument",&fArg); settings->FindInt32("do_what",(long *)&fDoWhat); if (fDoWhat == Z_SET_REPLY) settings->FindInt32("argument", &fReplyAccount); }
/* * Convert a local absolute filepath to a Dropbox one * by removing the <path to Dropbox> from the beginning */ BString local_to_db_filepath(const char * local_path) { BString s; s = BString(local_path); s.RemoveFirst(local_path_string); return s; }
void Parser::UpdateStatementType(Statement* statement) { if (statement->GetType() != Statement::kUnknown) return; BString* keyword = statement->GetKeyword(); Statement::Type type; if (keyword->FindFirst("Default") == 0) { type = Statement::kDefault; keyword->RemoveFirst("Default"); } else if (keyword->FindFirst("Param") == 0) { type = Statement::kParam; keyword->RemoveFirst("Param"); } else { type = Statement::kValue; } statement->SetType(type); }
BString MSHLanguageMgr::GetLanguageName(const int32 index) { BString languageName = ""; if (NULL != fTransFiles) { const int32 numLanguages = CountLanguages(); if ((numLanguages > 0) && (index < numLanguages)) { MSHLanguageFile* langFile = reinterpret_cast<MSHLanguageFile*>(fTransFiles->ItemAt(index)); if (NULL != langFile) { BString transFileName = langFile->GetTranslationFileName(); transFileName.RemoveFirst(fFileNameStub); transFileName.RemoveFirst("."); languageName = transFileName; } } } return languageName; }
BString EnumFlagProperty::GetValueAsString(void) const { BString out; for (int32 i = 0; i < CountValuePairs(); i++) { if (fValue & PairValueAt(i)) out << " | " << PairNameAt(i); } if (out.FindFirst(" | ") == 0) out.RemoveFirst(" | "); return out; }
void BudgetWindow::RefreshCategories(void) { fCategoryList->Clear(); fIncomeRow = new BRow(); fCategoryList->AddRow(fIncomeRow); fSpendingRow = new BRow(); fCategoryList->AddRow(fSpendingRow); fIncomeRow->SetField(new BStringField(TRANSLATE("Income")),0); fSpendingRow->SetField(new BStringField(TRANSLATE("Spending")),0); CppSQLite3Query query = gDatabase.DBQuery("select category,amount,period,isexpense from " "budgetlist order by category", "BudgetWindow::RefreshCategories"); float maxwidth=fCategoryList->StringWidth("Category"); while(!query.eof()) { BString cat = DeescapeIllegalCharacters(query.getStringField(0)); Fixed amount; amount.SetPremultiplied(query.getInt64Field(1)); BudgetPeriod period = (BudgetPeriod)query.getIntField(2); BRow *row = new BRow(); if(query.getIntField(3)==0) fCategoryList->AddRow(row,fIncomeRow); else fCategoryList->AddRow(row,fSpendingRow); row->SetField(new BStringField(cat.String()),0); BString amountstr; gDefaultLocale.CurrencyToString(amount.AbsoluteValue(),amountstr); amountstr.Truncate(amountstr.FindFirst(gDefaultLocale.CurrencyDecimal())); amountstr.RemoveFirst(gDefaultLocale.CurrencySymbol()); row->SetField(new BStringField(amountstr.String()),1); float tempwidth = fCategoryList->StringWidth(cat.String()); maxwidth = MAX(tempwidth,maxwidth); row->SetField(new BStringField(BudgetPeriodToString(period).String()),2); query.nextRow(); } fCategoryList->ColumnAt(0)->SetWidth(maxwidth+30); fCategoryList->ExpandOrCollapse(fIncomeRow,true); fCategoryList->ExpandOrCollapse(fSpendingRow,true); }
void JabberProtocol::ReceiveData(BMessage *msg) { BMessage packet; BString msgData; msg->MakeEmpty(); bool found_stream_start = false; bool found_stream_end = false; do { BString data; int32 length; packet.MakeEmpty(); socketAdapter->ReceiveData(&packet); packet.FindString("data", &data); packet.FindInt32("length", &length); if (data.FindFirst("<stream:stream") >= 0) found_stream_start = true; if (data.FindFirst("</stream:stream") >= 0) found_stream_end = true; msgData.Append(data); } while (FXMLCheck(msgData.String()) == NULL && !found_stream_start && !found_stream_end); // TODO: handle XML head more accurately msgData.RemoveFirst("<?xml version='1.0'?>").Append("</dengon>").Prepend("<dengon>"); msg->AddInt32("length", msgData.Length()); msg->AddString("data", msgData); }
/*static*/ void Playlist::AppendPlaylistToPlaylist(const entry_ref& ref, Playlist* playlist) { BEntry entry(&ref, true); if (entry.InitCheck() != B_OK || !entry.Exists()) return; BString mimeString = _MIMEString(&ref); if (_IsTextPlaylist(mimeString)) { //printf("RunPlaylist thing\n"); BFile file(&ref, B_READ_ONLY); FileReadWrite lineReader(&file); BString str; entry_ref refPath; status_t err; BPath path; while (lineReader.Next(str)) { str = str.RemoveFirst("file://"); str = str.RemoveLast(".."); path = BPath(str.String()); printf("Line %s\n", path.Path()); if (path.Path() != NULL) { if ((err = get_ref_for_path(path.Path(), &refPath)) == B_OK) { PlaylistItem* item = new (std::nothrow) FilePlaylistItem(refPath); if (item == NULL || !playlist->AddItem(item)) delete item; } else printf("Error - %s: [%lx]\n", strerror(err), (int32) err); } else printf("Error - No File Found in playlist\n"); } } else if (_IsBinaryPlaylist(mimeString)) { BFile file(&ref, B_READ_ONLY); Playlist temp; if (temp.Unflatten(&file) == B_OK) playlist->AdoptPlaylist(temp, playlist->CountItems()); } }
RuleFilter::RuleFilter(BMessage *settings) : BMailFilter(settings) { // attribute is adapted to our "capitalize-each-word-in-the-header" policy BString attr; settings->FindString("attribute",&attr); attr.CapitalizeEachWord(); attribute = strdup(attr.String()); BString regex; settings->FindString("regex",®ex); int32 index = regex.FindFirst("REGEX:"); if (index == B_ERROR || index > 0) EscapeRegexTokens(regex); else regex.RemoveFirst("REGEX:"); matcher.SetPattern(regex.String(),false); settings->FindString("argument",&arg); settings->FindInt32("do_what",(long *)&do_what); if (do_what == Z_SET_REPLY) settings->FindInt32("argument",&chain_id); }
void BudgetWindow::SetPeriod(const BudgetPeriod &period) { BRow *row = fCategoryList->CurrentSelection(); if(!row) return; BudgetEntry entry; BStringField *strfield = (BStringField*)row->GetField(0); if(!gDatabase.GetBudgetEntry(strfield->String(),entry)) return; // Convert the amount to reflect the change in period switch(entry.period) { case BUDGET_WEEKLY: { entry.amount *= 52; break; } case BUDGET_QUARTERLY: { entry.amount *= 4; break; } case BUDGET_ANNUALLY: { break; } default: { entry.amount *= 12; break; } } entry.period = period; switch(entry.period) { case BUDGET_WEEKLY: { entry.amount /= 52; break; } case BUDGET_QUARTERLY: { entry.amount /= 4; break; } case BUDGET_ANNUALLY: { break; } default: { entry.amount /= 12; break; } } // yeah, yeah, I know about rounding errors. It's not that big of a deal, // so deal with it. *famous last words* entry.amount.Round(); gDatabase.AddBudgetEntry(entry); RefreshBudgetGrid(); RefreshBudgetSummary(); BString str; gDefaultLocale.CurrencyToString(entry.amount,str); str.Truncate(str.FindFirst(gDefaultLocale.CurrencyDecimal())); str.RemoveFirst(gDefaultLocale.CurrencySymbol()); row->SetField(new BStringField(str.String()),1); fAmountBox->SetText(str.String()); row->SetField(new BStringField(BudgetPeriodToString(entry.period).String()),2); fCategoryList->UpdateRow(row); }
void BudgetWindow::RefreshBudgetSummary(void) { Fixed itotal,stotal,mtotal,f; Fixed irowtotal,srowtotal, ttotal; for(int32 i=0; i<12; i++) { itotal = stotal = mtotal = 0; for(int32 j=0; j<fIncomeGrid.CountItems(); j++) { fIncomeGrid.ValueAt(i,j,f); itotal += f; irowtotal += f; } for(int32 j=0; j<fSpendingGrid.CountItems(); j++) { fSpendingGrid.ValueAt(i,j,f); stotal += f.AbsoluteValue(); srowtotal += f; } mtotal = itotal - stotal; ttotal += mtotal; itotal.Round(); stotal.Round(); mtotal.Round(); BString itemp,stemp,mtemp; gDefaultLocale.CurrencyToString(itotal,itemp); gDefaultLocale.CurrencyToString(stotal,stemp); gDefaultLocale.CurrencyToString(mtotal,mtemp); itemp.Truncate(itemp.FindFirst(gDefaultLocale.CurrencyDecimal())); stemp.Truncate(stemp.FindFirst(gDefaultLocale.CurrencyDecimal())); mtemp.Truncate(mtemp.FindFirst(gDefaultLocale.CurrencyDecimal())); itemp.RemoveFirst(gDefaultLocale.CurrencySymbol()); stemp.RemoveFirst(gDefaultLocale.CurrencySymbol()); mtemp.RemoveFirst(gDefaultLocale.CurrencySymbol()); BRow *irow = fBudgetSummary->RowAt(0); BRow *srow = fBudgetSummary->RowAt(1); BRow *mrow = fBudgetSummary->RowAt(2); irow->SetField(new BStringField(itemp.String()),i+1); srow->SetField(new BStringField(stemp.String()),i+1); mrow->SetField(new BStringField(mtemp.String()),i+1); float colwidth = fBudgetSummary->StringWidth(itemp.String()) + 20; if(fBudgetSummary->ColumnAt(i+1)->Width() < colwidth) fBudgetSummary->ColumnAt(i+1)->SetWidth(colwidth); colwidth = fBudgetSummary->StringWidth(stemp.String()) + 20; if(fBudgetSummary->ColumnAt(i+1)->Width() < colwidth) fBudgetSummary->ColumnAt(i+1)->SetWidth(colwidth); colwidth = fBudgetSummary->StringWidth(mtemp.String()) + 20; if(fBudgetSummary->ColumnAt(i+1)->Width() < colwidth) fBudgetSummary->ColumnAt(i+1)->SetWidth(colwidth); } BString ttemp; gDefaultLocale.CurrencyToString(irowtotal,ttemp); ttemp.Truncate(ttemp.FindFirst(gDefaultLocale.CurrencyDecimal())); ttemp.RemoveFirst(gDefaultLocale.CurrencySymbol()); fBudgetSummary->RowAt(0)->SetField(new BStringField(ttemp.String()),13); gDefaultLocale.CurrencyToString(srowtotal,ttemp); ttemp.Truncate(ttemp.FindFirst(gDefaultLocale.CurrencyDecimal())); ttemp.RemoveFirst(gDefaultLocale.CurrencySymbol()); fBudgetSummary->RowAt(1)->SetField(new BStringField(ttemp.String()),13); gDefaultLocale.CurrencyToString(ttotal,ttemp); ttemp.Truncate(ttemp.FindFirst(gDefaultLocale.CurrencyDecimal())); ttemp.RemoveFirst(gDefaultLocale.CurrencySymbol()); fBudgetSummary->RowAt(2)->SetField(new BStringField(ttemp.String()),13); fBudgetSummary->Invalidate(); }
void BudgetWindow::HandleCategorySelection(void) { BRow *row = fCategoryList->CurrentSelection(); if(!row) { fAmountBox->SetText(""); fMonthly->SetValue(B_CONTROL_ON); fStatAverageRow->SetField(new BStringField(""),1); fStatHighestRow->SetField(new BStringField(""),1); fStatLowestRow->SetField(new BStringField(""),1); } BudgetEntry entry; BStringField *strfield = (BStringField*)row->GetField(0); if(!gDatabase.GetBudgetEntry(strfield->String(),entry)) return; switch(entry.period) { case BUDGET_WEEKLY: { fWeekly->SetValue(B_CONTROL_ON); break; } case BUDGET_QUARTERLY: { fQuarterly->SetValue(B_CONTROL_ON); break; } case BUDGET_ANNUALLY: { fAnnually->SetValue(B_CONTROL_ON); break; } default: { fMonthly->SetValue(B_CONTROL_ON); break; } } BString str; gDefaultLocale.CurrencyToString(entry.amount.AbsoluteValue(),str); str.Truncate(str.FindFirst(gDefaultLocale.CurrencyDecimal())); str.RemoveFirst(gDefaultLocale.CurrencySymbol()); fAmountBox->SetText(str.String()); Fixed high,low,avg; CalcStats(entry.name.String(),high,low,avg); gDefaultLocale.CurrencyToString(high.AbsoluteValue(),str); str.RemoveFirst(gDefaultLocale.CurrencySymbol()); fStatHighestRow->SetField(new BStringField(str.String()),1); gDefaultLocale.CurrencyToString(low.AbsoluteValue(),str); str.RemoveFirst(gDefaultLocale.CurrencySymbol()); fStatLowestRow->SetField(new BStringField(str.String()),1); gDefaultLocale.CurrencyToString(avg.AbsoluteValue(),str); str.RemoveFirst(gDefaultLocale.CurrencySymbol()); fStatAverageRow->SetField(new BStringField(str.String()),1); fCatStat->Invalidate(); }
nsresult nsOSHelperAppService::SetMIMEInfoForType(const char *aMIMEType, nsMIMEInfoBeOS**_retval) { LOG(("-- nsOSHelperAppService::SetMIMEInfoForType: %s\n",aMIMEType)); nsresult rv = NS_ERROR_FAILURE; nsMIMEInfoBeOS* mimeInfo = new nsMIMEInfoBeOS(aMIMEType); if (mimeInfo) { NS_ADDREF(mimeInfo); BMimeType mimeType(aMIMEType); BMessage data; int32 index = 0; BString strData; LOG((" Adding extensions:\n")); if (mimeType.GetFileExtensions(&data) == B_OK) { while (data.FindString("extensions",index,&strData) == B_OK) { // if the file extension includes the '.' then we don't want to include that when we append // it to the mime info object. if (strData.ByteAt(0) == '.') strData.RemoveFirst("."); mimeInfo->AppendExtension(nsDependentCString(strData.String())); LOG((" %s\n",strData.String())); index++; } } char desc[B_MIME_TYPE_LENGTH + 1]; if (mimeType.GetShortDescription(desc) == B_OK) { mimeInfo->SetDescription(NS_ConvertUTF8toUCS2(desc)); } else { if (mimeType.GetLongDescription(desc) == B_OK) { mimeInfo->SetDescription(NS_ConvertUTF8toUCS2(desc)); } else { mimeInfo->SetDescription(NS_ConvertUTF8toUCS2(aMIMEType)); } } LOG((" Description: %s\n",desc)); //set preferred app and app description char appSig[B_MIME_TYPE_LENGTH + 1]; bool doSave = true; if (mimeType.GetPreferredApp(appSig) == B_OK) { LOG((" Got preferred ap\n")); BMimeType app(appSig); entry_ref ref; BEntry entry; BPath path; if ((app.GetAppHint(&ref) == B_OK) && (entry.SetTo(&ref, false) == B_OK) && (entry.GetPath(&path) == B_OK)) { LOG((" Got our path!\n")); nsCOMPtr<nsIFile> handlerFile; rv = GetFileTokenForPath(NS_ConvertUTF8toUCS2(path.Path()).get(), getter_AddRefs(handlerFile)); if (NS_SUCCEEDED(rv)) { mimeInfo->SetDefaultApplication(handlerFile); mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault); mimeInfo->SetDefaultDescription(NS_ConvertUTF8toUCS2(path.Leaf())); LOG((" Preferred App: %s\n",path.Leaf())); doSave = false; } } } if (doSave) { mimeInfo->SetPreferredAction(nsIMIMEInfo::saveToDisk); LOG((" No Preferred App\n")); } *_retval = mimeInfo; rv = NS_OK; } else rv = NS_ERROR_FAILURE; return rv; }
void Project::Link(void) { BString linkString; if (TargetType() == TARGET_STATIC_LIB) { linkString = "ar rcs '"; linkString << GetPath().GetFolder() << "/" << GetTargetName() << "' "; for (int32 i = 0; i < CountGroups(); i++) { SourceGroup *group = GroupAt(i); for (int32 j = 0; j < group->filelist.CountItems(); j++) { SourceFile *file = group->filelist.ItemAt(j); if (file->GetObjectPath(fBuildInfo).GetFullPath()) linkString << "'" << file->GetObjectPath(fBuildInfo).GetFullPath() << "' "; } } } else { linkString = "gcc -o '"; linkString << GetPath().GetFolder() << "/" << GetTargetName() << "' "; for (int32 i = 0; i < CountGroups(); i++) { SourceGroup *group = GroupAt(i); for (int32 j = 0; j < group->filelist.CountItems(); j++) { SourceFile *file = group->filelist.ItemAt(j); if (file->GetObjectPath(fBuildInfo).GetFullPath()) linkString << "'" << file->GetObjectPath(fBuildInfo).GetFullPath() << "' "; } } for (int32 i = 0; i < CountGroups(); i++) { SourceGroup *group = GroupAt(i); for (int32 j = 0; j < group->filelist.CountItems(); j++) { SourceFile *file = group->filelist.ItemAt(j); if (file->GetLibraryPath(fBuildInfo).GetFullPath()) linkString << "'" << file->GetLibraryPath(fBuildInfo).GetFullPath() << "' "; } } for (int32 i = 0; i < CountLibraries(); i++) { SourceFile *file = LibraryAt(i); if (!file) continue; BString filenamebase; filenamebase = file->GetPath().GetBaseName(); if (filenamebase.FindFirst("lib") == 0) filenamebase.RemoveFirst("lib"); linkString << "-l" << filenamebase << " "; } if (TargetType() == TARGET_DRIVER) linkString << "/boot/develop/lib/x86/_KERNEL_ "; linkString << "-L/boot/home/config/lib "; switch (TargetType()) { case TARGET_DRIVER: { linkString << "-Xlinker -nostdlib "; break; } case TARGET_SHARED_LIB: { linkString << "-nostart -Xlinker -soname=" << GetTargetName() << " "; break; } default: { // Application linkString << "-Xlinker -soname=_APP_ "; break; } } } linkString << " 2>&1"; BString errmsg; PipeCommand(linkString.String(),errmsg); STRACE(1,("Linking %s:\n%s\nErrors:\n%s\n",GetName(),linkString.String(),errmsg.String())); if (errmsg.CountChars() > 0) ParseLDErrors(errmsg.String(),fBuildInfo.errorList); }
void ProjectWindow::ActOnSelectedFiles(const int32 &command) { SCMOutputWindow *win = NULL; switch (command) { case M_ADD_SELECTION_TO_REPO: { if (!fSourceControl) return; win = new SCMOutputWindow(TR("Add to Repository")); win->Show(); break; } case M_REMOVE_SELECTION_FROM_REPO: { if (!fSourceControl) return; win = new SCMOutputWindow(TR("Remove from Repository")); win->Show(); break; } case M_REVERT_SELECTION: { if (!fSourceControl) return; win = new SCMOutputWindow(TR("Revert")); win->Show(); break; } case M_DIFF_SELECTION: { if (!fSourceControl) return; win = new SCMOutputWindow(TR("Show Differences")); win->Show(); break; } default: break; } for (int32 i = 0; i < fProjectList->CountItems(); i++) { SourceFileItem *item = dynamic_cast<SourceFileItem*>(fProjectList->ItemAt(i)); if (item && item->IsSelected()) { SourceFile *file = item->GetData(); BString relPath = file->GetPath().GetFullPath(); if (relPath.FindFirst(fProject->GetPath().GetFolder()) == 0) { relPath.RemoveFirst(fProject->GetPath().GetFolder()); relPath.RemoveFirst("/"); } BString relPartnerPath; entry_ref partnerRef = GetPartnerRef(file->GetPath().GetRef()); if (partnerRef.name) { DPath partnerPath(partnerRef); relPartnerPath = partnerPath.GetFullPath(); if (relPartnerPath.FindFirst(fProject->GetPath().GetFolder()) == 0) { relPartnerPath.RemoveFirst(fProject->GetPath().GetFolder()); relPartnerPath.RemoveFirst("/"); } } switch (command) { case M_REBUILD_FILE: { if (file->UsesBuild()) { file->RemoveObjects(*fProject->GetBuildInfo()); item->SetDisplayState(SFITEM_NEEDS_BUILD); fProjectList->InvalidateItem(fProjectList->IndexOf(item)); } break; } case M_ADD_SELECTION_TO_REPO: { fSourceControl->AddToRepository(relPath.String()); if (relPartnerPath.CountChars() > 0) fSourceControl->AddToRepository(relPartnerPath.String()); break; } case M_REMOVE_SELECTION_FROM_REPO: { fSourceControl->RemoveFromRepository(relPath.String()); if (relPartnerPath.CountChars() > 0) fSourceControl->RemoveFromRepository(relPartnerPath.String()); break; } case M_REVERT_SELECTION: { fSourceControl->Revert(relPath.String()); break; } case M_DIFF_SELECTION: { fSourceControl->Diff(relPath.String()); break; } default: { return; } } } } }
status_t BeIDE2Paladin(const char *path, BString &outpath) { status_t returnVal = BEntry(path).InitCheck(); if (returnVal != B_OK) return returnVal; BeIDEProject beide(path); if (beide.InitCheck() != B_OK) return beide.InitCheck(); DPath dpath(path); Project proj(dpath.GetBaseName(), beide.TargetName()); proj.SetPlatform(PLATFORM_R5); // NOTE: TARGET_* from Project.h & TARGET_* from BeIDEPRoject.h // map perfectly, so no explicit conversion required proj.SetTargetType(beide.TargetType()); BString savepath(dpath.GetFolder()); savepath << "/" << dpath.GetBaseName() << ".pld"; proj.Save(savepath.String()); for (int32 i = 0; i < beide.CountLocalIncludes(); i++) { BString include = beide.LocalIncludeAt(i); if (include.ICompare("{project}") == 0) continue; include.RemoveFirst("{project}/"); proj.AddLocalInclude(include.String()); } for (int32 i = 0; i < beide.CountSystemIncludes(); i++) { BString include = beide.SystemIncludeAt(i); if (include.ICompare("{project}") == 0) continue; include.RemoveFirst("{project}/"); proj.AddSystemInclude(include.String()); } SourceGroup *currentGroup = NULL; for (int32 i = 0; i < beide.CountFiles(); i++) { ProjectFile file = beide.FileAt(i); if (file.path.FindFirst("/_KERNEL_") > 0) continue; SourceFile *srcFile = gFileFactory.CreateSourceFileItem(file.path.String()); if (!srcFile) continue; if (dynamic_cast<SourceFileLib*>(srcFile)) { proj.AddLibrary(srcFile->GetPath().GetFileName()); delete srcFile; continue; } if (!proj.HasGroup(file.group.String())) currentGroup = proj.AddGroup(file.group.String()); BPath newPath; if (proj.LocateFile(srcFile->GetPath().GetFullPath(), newPath)) srcFile->SetPath(newPath.Path()); proj.AddFile(srcFile, currentGroup); } uint32 codeFlags = beide.CodeGenerationFlags(); if (codeFlags & CODEGEN_DEBUGGING) proj.SetDebug(true); if (codeFlags & CODEGEN_OPTIMIZE_SIZE) proj.SetOpForSize(true); proj.SetOpLevel(beide.OptimizationMode()); // Because Paladin doesn't currently support the seemingly 50,000 warning // types, we'll put them in the compiler options for the ones not commonly // used BString options; uint32 warnings = beide.Warnings(); if (warnings & WARN_STRICT_ANSI) options << "-pedantic "; if (warnings & WARN_LOCAL_SHADOW) options << "-Wshadow "; if (warnings & WARN_INCOMPATIBLE_CAST) options << "-Wbad-function-cast "; if (warnings & WARN_CAST_QUALIFIERS) options << "-Wcast-qual "; if (warnings & WARN_CONFUSING_CAST) options << "-Wconversion "; if (warnings & WARN_CANT_INLINE) options << "-Winline "; if (warnings & WARN_EXTERN_TO_INLINE) options << "-Wextern-inline "; if (warnings & WARN_OVERLOADED_VIRTUALS) options << "-Woverloaded-virtual "; if (warnings & WARN_C_CASTS) options << "-Wold-style-cast "; if (warnings & WARN_EFFECTIVE_CPP) options << "-Weffc++ "; if (warnings & WARN_MISSING_PARENTHESES) options << "-Wparentheses "; if (warnings & WARN_INCONSISTENT_RETURN) options << "-Wreturn-type "; if (warnings & WARN_MISSING_ENUM_CASES) options << "-Wswitch "; if (warnings & WARN_UNUSED_VARS) options << "-Wunusued "; if (warnings & WARN_UNINIT_AUTO_VARS) options << "-Wuninitialized "; if (warnings & WARN_INIT_REORDERING) options << "-Wreorder "; if (warnings & WARN_NONVIRTUAL_DESTRUCTORS) options << "-Wnon-virtual-dtor "; if (warnings & WARN_UNRECOGNIZED_PRAGMAS) options << "-Wunknown-pragmas "; if (warnings & WARN_SIGNED_UNSIGNED_COMP) options << "-Wsign-compare "; if (warnings & WARN_CHAR_SUBSCRIPTS) options << "-Wchar-subscripts "; if (warnings & WARN_PRINTF_FORMATTING) options << "-Wformat "; if (warnings & WARN_TRIGRAPHS_USED) options << "-Wtrigraphs "; uint32 langopts = beide.LanguageOptions(); if (langopts & LANGOPTS_ANSI_C_MODE) options << "-ansi "; if (langopts & LANGOPTS_SUPPORT_TRIGRAPHS) options << "-trigraphs "; if (langopts & LANGOPTS_SIGNED_CHAR) options << "-fsigned-char "; if (langopts & LANGOPTS_UNSIGNED_BITFIELDS) options << "-funsigned-bitfields "; if (langopts & LANGOPTS_CONST_CHAR_LITERALS) options << "-Wwrite-strings "; options << beide.ExtraCompilerOptions(); proj.SetExtraCompilerOptions(options.String()); proj.SetExtraLinkerOptions(beide.ExtraLinkerOptions()); proj.Save(); outpath = savepath; return B_OK; }
bool ServerWindow::ParseEvents (const char *data) { BString firstWord = GetWord(data, 1).ToUpper(); BString secondWord = GetWord(data, 2).ToUpper(); if(firstWord == "PING") { BString tempString, theServer (GetWord(data, 2)); theServer.RemoveFirst(":"); tempString << "PONG " << myNick << " " << theServer; SendData (tempString.String()); tempString = ""; tempString << "PONG " << theServer; // fix for some noncompliant servers SendData (tempString.String()); return true; } if (secondWord == "JOIN") { BString nick (GetNick (data)); BString channel (GetWord (data, 3)); channel.RemoveFirst (":"); ClientWindow *client (Client (channel.String())); if (nick == myNick) { if (!client) { client = new ChannelWindow ( channel.String(), sid, serverName.String(), sMsgr, myNick.String()); clients.AddItem (client); client->Show(); } BString tempString ("MODE "); tempString << channel; SendData (tempString.String()); } else if (client) { // someone else BString ident (GetIdent (data)); BString address (GetAddress (data)); const char *expansions[3]; BString tempString, addy; expansions[0] = nick.String(); expansions[1] = ident.String(); expansions[2] = address.String(); tempString = ExpandKeyed (events[E_JOIN], "NIA", expansions); BMessage display (M_DISPLAY); PackDisplay ( &display, tempString.String(), &joinColor, 0, true); addy << ident << "@" << address; BMessage aMsg (M_IS_IGNORED), reply; bool ignored; aMsg.AddString ("server", serverName.String()); aMsg.AddString ("nick", nick.String()); aMsg.AddString ("address", addy.String()); be_app_messenger.SendMessage (&aMsg, &reply); reply.FindBool ("ignored", &ignored); BMessage msg (M_USER_ADD); msg.AddString ("nick", nick.String()); msg.AddBool ("ignore", ignored); msg.AddMessage ("display", &display); client->PostMessage (&msg); } return true; } if (secondWord == "PART") { BString nick (GetNick (data)); BString channel (GetWord (data, 3)); ClientWindow *client; if ((client = Client (channel.String())) != 0) { BString ident (GetIdent (data)); BString address (GetAddress (data)); const char *expansions[3]; BString buffer; expansions[0] = nick.String(); expansions[1] = ident.String(); expansions[2] = address.String(); buffer = ExpandKeyed (events[E_PART], "NIA", expansions); BMessage display (M_DISPLAY); PackDisplay (&display, buffer.String(), &joinColor, 0, true); BMessage msg (M_USER_QUIT); msg.AddString ("nick", nick.String()); msg.AddMessage ("display", &display); client->PostMessage (&msg); } return true; } if(secondWord == "PRIVMSG") { BString theNick (GetNick (data)), ident (GetIdent (data)), address (GetAddress (data)), addy; addy << ident << "@" << address; BMessage aMsg (M_IS_IGNORED), reply; bool ignored; aMsg.AddString ("server", serverName.String()); aMsg.AddString ("nick", theNick.String()); aMsg.AddString ("address", addy.String()); be_app_messenger.SendMessage (&aMsg, &reply); reply.FindBool ("ignored", &ignored); if (ignored) { BMessage msg (M_IGNORED_PRIVMSG); const char *rule; reply.FindString ("rule", &rule); msg.AddString ("nick", theNick.String()); msg.AddString ("address", addy.String()); msg.AddString ("rule", rule); Broadcast (&msg); return true; } BString theTarget (GetWord (data, 3).ToUpper()), theTargetOrig (GetWord (data, 3)), theMsg (RestOfString (data, 4)); ClientWindow *client (0); theMsg.RemoveFirst(":"); if(theMsg[0] == '\1' && GetWord(theMsg.String(), 1) != "\1ACTION") // CTCP { ParseCTCP (theNick, theTargetOrig, theMsg); return true; } if (theTarget[0] == '#') client = Client (theTarget.String()); else if (!(client = Client (theNick.String()))) { BString ident = GetIdent(data); BString address = GetAddress(data); BString addyString; addyString << ident << "@" << address; client = new MessageWindow ( theNick.String(), sid, serverName.String(), sMsgr, myNick.String(), addyString.String(), false, // not a dcc chat true); // initated by server clients.AddItem (client); client->Show(); } if (client) client->ChannelMessage ( theMsg.String(), theNick.String(), ident.String(), address.String()); return true; } if (secondWord == "NICK") { BString oldNick (GetNick (data)), ident (GetIdent (data)), address (GetAddress (data)), newNick (GetWord (data, 3)), buffer; const char *expansions[4]; newNick.RemoveFirst (":"); expansions[0] = oldNick.String(); expansions[1] = newNick.String(); expansions[2] = ident.String(); expansions[3] = address.String(); buffer = ExpandKeyed (events[E_NICK], "NnIA", expansions); BMessage display (M_DISPLAY); PackDisplay (&display, buffer.String(), &nickColor, 0, bowser_app->GetStampState()); BMessage msg (M_CHANGE_NICK); msg.AddString ("oldnick", oldNick.String()); msg.AddString ("newnick", newNick.String()); msg.AddString ("ident", ident.String()); msg.AddString ("address", address.String()); msg.AddMessage ("display", &display); Broadcast (&msg); // Gotta change the server as well! if (myNick.ICompare (oldNick) == 0) { myNick = newNick; status->SetItemValue (STATUS_NICK, newNick.String()); } bowser_app->PostMessage (&msg); // for ignores return true; } if (secondWord == "QUIT") { BString theNick (GetNick (data).String()), theRest (RestOfString (data, 3)), ident (GetIdent (data)), address (GetAddress (data)), theMsg, firstNick; const char *expansions[4]; theRest.RemoveFirst (":"); expansions[0] = theNick.String(); expansions[1] = theRest.String(); expansions[2] = ident.String(); expansions[3] = address.String(); theMsg = ExpandKeyed (events[E_QUIT], "NRIA", expansions); BMessage display (M_DISPLAY); PackDisplay (&display, theMsg.String(), &quitColor, 0, true); BMessage msg (M_USER_QUIT); msg.AddMessage ("display", &display); msg.AddString ("nick", theNick.String()); Broadcast (&msg); // see if it was our first nickname. if so, change firstNick = (const char *)lnicks->ItemAt (0); if (theNick == firstNick) { BString tempCmd ("/nick "); tempCmd << firstNick; ParseCmd (tempCmd.String()); } return true; } if (secondWord == "KICK") { BString kicker (GetNick (data)), kickee (GetWord (data, 4)), rest (RestOfString (data, 5)), channel (GetWord (data, 3)); ClientWindow *client (Client (channel.String())); rest.RemoveFirst (":"); if ((client = Client (channel.String())) != 0 && kickee == myNick) { BMessage display (M_DISPLAY); // "you were kicked" BString buffer; buffer << "*** You have been kicked from " << channel << " by " << kicker << " (" << rest << ")\n"; PackDisplay (&display, buffer.String(), &quitColor, 0, true); BMessage display2 (M_DISPLAY); // "attempting auto rejoin" buffer = "*** Attempting to automagically rejoin "; buffer << channel << "...\n"; PackDisplay (&display2, buffer.String(), &quitColor, 0, true); BMessage msg (M_CHANNEL_GOT_KICKED); msg.AddString ("channel", channel.String()); msg.AddMessage ("display", &display); // "you were kicked" msg.AddMessage ("display2", &display2); // "attempting auto rejoin" client->PostMessage (&msg); } if (client && kickee != myNick) { BMessage display (M_DISPLAY); const char *expansions[4]; BString buffer; expansions[0] = kickee.String(); expansions[1] = channel.String(); expansions[2] = kicker.String(); expansions[3] = rest.String(); buffer = ExpandKeyed (events[E_KICK], "NCnR", expansions); PackDisplay (&display, buffer.String(), &quitColor, 0, true); BMessage msg (M_USER_QUIT); msg.AddString ("nick", kickee.String()); msg.AddMessage ("display", &display); client->PostMessage (&msg); } return true; } if(secondWord == "TOPIC") { BString theNick (GetNick (data)), theChannel (GetWord (data, 3)), theTopic (RestOfString (data, 4)); ClientWindow *client (Client (theChannel.String())); theTopic.RemoveFirst (":"); if (client && client->Lock()) { BString ident (GetIdent (data)); BString address (GetAddress (data)); const char *expansions[5]; BString buffer; expansions[0] = theNick.String(); expansions[1] = theTopic.String(); expansions[2] = client->Id().String(); expansions[3] = ident.String(); expansions[4] = address.String(); if(bowser_app->GetShowTopicState()) { buffer << client->Id() << " : " << theTopic; client->SetTitle (buffer.String()); client->Unlock(); } else { buffer << client->Id(); client->SetTitle (buffer.String()); client->Unlock(); } BMessage topic (M_CHANNEL_TOPIC); topic.AddString("topic", theTopic.String()); BMessage display (M_DISPLAY); buffer = ExpandKeyed (events[E_TOPIC], "NTCIA", expansions); PackDisplay (&display, buffer.String(), &whoisColor, 0, true); topic.AddMessage("display", &display); client->PostMessage (&topic); } return true; } if (secondWord == "MODE") { BString theNick (GetNick (data)), theChannel (GetWord (data, 3)), theMode (GetWord (data, 4)), theTarget (RestOfString (data, 5)); ClientWindow *client (Client (theChannel.String())); if (client) { BMessage msg (M_CHANNEL_MODE); msg.AddString("nick", theNick.String()); msg.AddString("mode", theMode.String()); msg.AddString("target", theTarget.String()); client->PostMessage (&msg); } else { BMessage msg (M_DISPLAY); BString buffer; theMode.RemoveFirst(":"); buffer << "*** User mode changed: " << theMode << "\n"; PackDisplay (&msg, buffer.String(), 0, 0, true); PostActive (&msg); } return true; } if(firstWord == "NOTICE") // _server_ notice { BString theNotice (RestOfString(data, 3)); const char *expansions[1]; theNotice.RemoveFirst(":"); expansions[0] = theNotice.String(); theNotice = ExpandKeyed (events[E_SNOTICE], "R", expansions); Display (theNotice.String(), 0, 0, true); return true; } if (firstWord == "ERROR") // server error (on connect?) { BString theError (RestOfString (data, 2)); theError.RemoveAll (":"); theError.Append ("\n"); Display (theError.String(), &quitColor); isConnecting = false; return true; } if(secondWord == "NOTICE") // _user_ notice { BString theNick (GetNick (data)), ident (GetIdent (data)), address (GetAddress (data)), addy; addy << theNick << "@" << address; BMessage aMsg (M_IS_IGNORED), reply; bool ignored; aMsg.AddString ("server", serverName.String()); aMsg.AddString ("nick", theNick.String()); aMsg.AddString ("address", addy.String()); be_app_messenger.SendMessage (&aMsg, &reply); reply.FindBool ("ignored", &ignored); if (ignored) return true; BString theNotice = RestOfString(data, 4); theNotice.RemoveFirst(":"); if(theNotice[0] == '\1') { ParseCTCPResponse(theNick, theNotice); return true; } const char *expansions[4]; BString tempString; expansions[0] = theNick.String(); expansions[1] = theNotice.String(); expansions[2] = ident.String(); expansions[3] = address.String(); tempString = ExpandKeyed (events[E_UNOTICE], "NRIA", expansions); BMessage display (M_DISPLAY); PackDisplay (&display, tempString.String(), ¬iceColor, 0, true); PostActive (&display); return true; } return ParseENums (data, secondWord.String()); }
bool ServerAgent::ParseENums (const char *data, const char *sWord) { int num (atoi (sWord)); switch (num) { case ZERO: // 0 { // 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); if (difference > 0) { int32 secs (difference / 1000000); int32 milli (difference / 1000 - secs * 1000); char lag[15] = ""; sprintf (lag, "%0" B_PRId32 ".%03" B_PRId32, secs, milli); fMyLag = lag; 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 case RPL_MYINFO: // 004 { fConnected = true; fIsConnecting = false; fInitialMotd = true; fRetry = 0; if (num == RPL_WELCOME) { BString message = B_TRANSLATE("Established"); message.Prepend("[@] ").Append("\n"); Display(message.String(), C_ERROR, C_BACKGROUND, F_SERVER); } if (fNetworkData.FindBool ("lagCheck")) { fMyLag = "0.000"; fMsgr.SendMessage (M_LAG_CHANGED); } BString theNick (GetWord (data, 3)); fMyNick = theNick; if (!IsHidden()) vision_app->pClientWin()->pStatusView()->SetItemValue (STATUS_NICK, theNick.String()); BString theMsg (RestOfString (data, 4)); theMsg.RemoveFirst (":"); theMsg.Prepend ("* "); theMsg.Append ("\n"); Display (theMsg.String()); if (num == RPL_MYINFO) { // set "real" hostname fServerHostName = (GetWord (data, 1)); fServerHostName.RemoveFirst (":"); BString hostName (fId.String()); hostName += " - ["; 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 // identifier for now else if ((theMsg.FindFirst("UltimateIRCd") > 0) || (theMsg.FindFirst("Unreal") > 0)) fIrcdtype = IRCD_ULTIMATE; else if (theMsg.FindFirst("comstud") > 0) fIrcdtype = IRCD_COMSTUD; else if (theMsg.FindFirst("u2.") > 0) fIrcdtype = IRCD_UNDERNET; else if (theMsg.FindFirst("PTlink") > 0) fIrcdtype = IRCD_PTLINK; else if (theMsg.FindFirst ("CR") > 0) 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"); switch (fIrcdtype) { case IRCD_NEWNET: { // RPL_NNMAP Display (theMsg.String()); } break; default: { // RPL_PROTOCTL theMsg.Prepend ("* "); Display (theMsg.String()); } } } return true; case RPL_LUSERHIGHESTCONN: // 250 case RPL_LUSERCLIENT: // 251 case RPL_LUSEROP: // 252 case RPL_LUSERUNKNOWN: // 253 case RPL_LUSERCHANNELS: // 254 case RPL_LUSERME: // 255 case RPL_LUSERLOCAL: // 265 case RPL_LUSERGLOBAL: // 266 { BString theMsg (RestOfString (data, 4)); theMsg.RemoveFirst (":"); theMsg.Prepend ("* "); theMsg.Append ("\n"); Display (theMsg.String()); } return true; /// strip and send to server agent /// case RPL_ULMAP: // 006 case RPL_ULMAPEND: // 007 case RPL_U2MAP: // 015 case RPL_U2MAPEND: // 017 case RPL_TRACELINK: // 200 case RPL_TRACECONNECTING: // 201 case RPL_TRACEHANDSHAKE: // 202 case RPL_TRACEUNKNOWN: // 203 case RPL_TRACEOPERATOR: // 204 case RPL_TRACEUSER: // 205 case RPL_TRACESERVER: // 206 case RPL_TRACENEWTYPE: // 208 case RPL_TRACECLASS: // 209 case RPL_STATSLINKINFO: // 211 case RPL_STATSCOMMANDS: // 212 case RPL_STATSCLINE: // 213 case RPL_STATSNLINE: // 214 case RPL_STATSILINE: // 215 case RPL_STATSKLINE: // 216 case RPL_STATSQLINE: // 217 case RPL_STATSYLINE: // 218 case RPL_ENDOFSTATS: // 219 case RPL_STATSBLINE: // 220 case RPL_DALSTATSE: // 223 case RPL_DALSTATSF: // 224 case RPL_DALSTATSZ: // 225 case RPL_DALSTATSN: // 226 case RPL_DALSTATSG: // 227 case RPL_STATSLLINE: // 241 case RPL_STATSUPTIME: // 242 case RPL_STATSOLINE: // 243 case RPL_STATSHLINE: // 244 case RPL_STATSSLINE: // 245 case RPL_DALSTATSX: // 246 case RPL_STATSXLINE: // 247 case RPL_STATSPLINE: // 249 case RPL_ADMINME: // 256 case RPL_ADMINLOC1: // 257 case RPL_ADMINLOC2: // 258 case RPL_ADMINEMAIL: // 259 case RPL_TRACELOG: // 261 case RPL_ENDOFTRACE: // 262 case RPL_SILELIST: // 271 case RPL_ENDOFSILELIST: // 272 case RPL_ENDOFWHO: // 315 case RPL_CHANSERVURL: // 328 case RPL_COMMANDSYNTAX: // 334 case RPL_VERSION: // 351 case RPL_WHOREPLY: // 352 case RPL_BANLIST: // 367 case RPL_ENDOFBANLIST: // 368 case RPL_INFO: // 371 case RPL_ENDOFINFO: // 374 case RPL_YOUREOPER: // 381 case RPL_REHASHING: // 382 case RPL_TIME: // 391 case ERR_NOORIGIN: // 409 case ERR_NOTEXTTOSEND: // 412 case ERR_TOOMANYAWAY: // 429 case ERR_NICKCHANGETOOFAST: // 438 case ERR_TARGETCHANGETOOFAST: // 439 case ERR_SUMMONDISABLED: // 445 case ERR_USERSDISABLED: // 446 case ERR_NOTREGISTERED: // 451 case ERR_NEEDMOREPARMS: // 461 case ERR_PASSWDMISMATCH: // 464 case ERR_YOUREBANNEDCREEP: // 465 case ERR_NOPRIVILEGES: // 481 case ERR_NOOPERHOST: // 491 case ERR_USERSDONTMATCH: // 502 case ERR_SILELISTFULL: // 511 case ERR_TOOMANYWATCH: // 512 case ERR_TOOMANYDCC: // 514 case ERR_CANTINVITE: // 518 case ERR_LISTSYNTAX: // 521 case ERR_WHOSYNTAX: // 522 case ERR_WHOLIMEXCEED: // 523 case RPL_LOGON: // 600 case RPL_LOGOFF: // 601 case RPL_WATCHOFF: // 602 case RPL_WATCHSTAT: // 603 case RPL_NOWON: // 604 case RPL_NOWOFF: // 605 case RPL_WATCHLIST: // 606 case RPL_ENDOFWATCHLIST: // 607 case RPL_DCCALLOWLIST: // 618 case RPL_DCCALLOWEND: // 619 case RPL_DCCALLOW: // 620 { BString tempString (RestOfString (data, 4)); tempString.RemoveFirst (":"); tempString.Append ("\n"); Display (tempString.String()); } return true; case RPL_UMODEIS: // 221 { BString theMode (GetWord (data, 4)); BString tempString = B_TRANSLATE("Your current mode is %1"); tempString.ReplaceFirst("%1", 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 case RPL_NOWAWAY: // 306 case ERR_NOSUCHNICK: // 401 case ERR_NOSUCHSERVER: // 402 case ERR_NOSUCHCHANNEL: // 403 case ERR_CANNOTSENDTOCHAN: // 404 case ERR_TOOMANYCHANNELS: // 405 case ERR_WASNOSUCHNICK: // 406 case ERR_TOOMANYTARGETS: // 407 case ERR_NOCOLORSONCHAN: // 408 case ERR_YOUCANTDOTHAT: // 460 case ERR_CHANOPRIVSNEEDED: // 482 { BString tempString ("[x] "); if (num == ERR_CHANOPRIVSNEEDED) tempString += RestOfString (data, 5); else 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); } return true; case RPL_AWAY: // 301 { BString theNick (GetWord(data, 4)); BString tempString ("[x] "), theReason (RestOfString(data, 5)); theReason.RemoveFirst(":"); tempString += "Away: "; tempString += theReason; tempString += '\n'; if (fRemoteAwayMessages.find(theNick) != fRemoteAwayMessages.end()) { if (fRemoteAwayMessages[theNick] == theReason) { return true; } } fRemoteAwayMessages[theNick] = theReason; BMessage msg (M_DISPLAY); PackDisplay (&msg, tempString.String(), C_WHOIS, C_BACKGROUND, F_SERVER); PostActive (&msg); } return true; case RPL_USERHOST: // 302 { BString theHost (GetWord (data, 4)), theHostname (GetAddress (theHost.String())); theHost.RemoveFirst (":"); BString tempString (RestOfString (data, 4)); tempString.RemoveFirst (":"); tempString.Append ("\n"); Display (tempString.String()); if (fGetLocalIP && (tempString.IFindFirst (fMyNick.String()) == 0)) { fGetLocalIP = false; struct addrinfo *info; struct addrinfo hints; memset(&hints, 0, sizeof(addrinfo)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; int result = getaddrinfo(theHostname.String(), NULL, &hints, &info); if (result == 0) { char addr_buf[INET6_ADDRSTRLEN]; getnameinfo(info->ai_addr, info->ai_addrlen, addr_buf, sizeof(addr_buf), NULL, 0, NI_NUMERICHOST); fLocalip = addr_buf; printf("Got address: %s\n", fLocalip.String()); freeaddrinfo(info); return true; } } } 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))); int32 nickidx (nicks.IFindFirst(item->Text())); // make sure that the nick isn't a partial match. if ((nickidx >= 0) && ((nicks[nickidx + strlen(item->Text())] == ' ') || (nicks[nickidx + strlen(item->Text())] == '\0'))) { if (item->GetState() != true) { item->SetState (true); hasChanged = 1; if (onlined.Length()) onlined << ", "; onlined << item->Text(); #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 } } else { if (item->GetState() == true) { item->SetState (false); hasChanged = 2; if (offlined.Length()) offlined << ", "; offlined << item->Text(); #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 } } #ifdef __HAIKU__ 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(); } #endif } fNotifyNicks.SortItems(SortNotifyItems); msg.AddPointer ("list", &fNotifyNicks); msg.AddPointer ("source", this); msg.AddInt32 ("change", hasChanged); 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()); return true; } BMessage display (M_DISPLAY); BString buffer; buffer += "[x] "; buffer += theInfo; buffer += "\n"; PackDisplay (&display, buffer.String(), C_WHOIS, C_BACKGROUND, F_SERVER); PostActive (&display); } return true; case RPL_WHOISADMIN: // 308 case RPL_WHOISSERVICESADMIN: // 309 case RPL_WHOISHELPOP: // 310 case RPL_WHOISOPERATOR: // 313 case RPL_WHOISREGNICK: // 320 case RPL_WHOISACTUALLY: // 338 case RPL_WHOISMASK: // 550 case RPL_WHOWASIP: // 612 case RPL_WHOISUSERMODESALT: // 614 case RPL_WHOISUSERMODES: // 615 case RPL_WHOISREALHOSTNAME: // 616 { BString theInfo (RestOfString (data, 5)); theInfo.RemoveFirst (":"); BMessage display (M_DISPLAY); BString buffer; buffer += "[x] "; buffer += theInfo; buffer += "\n"; PackDisplay (&display, buffer.String(), C_WHOIS, C_BACKGROUND, F_SERVER); PostActive (&display); } return true; case RPL_WHOISUSER: // 311 { BString theNick (GetWord (data, 4)), theIdent (GetWord (data, 5)), theAddress (GetWord (data, 6)), theName (RestOfString (data, 8)); theName.RemoveFirst (":"); BMessage display (M_DISPLAY); BString buffer; buffer += "[x] "; buffer += theNick; buffer += " ("; buffer += theIdent; buffer += "@"; buffer += theAddress; buffer += ")\n"; 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; buffer += "[x] Server: "; buffer += theServer; buffer += " ("; buffer += theInfo; buffer += ")\n"; PackDisplay (&display, buffer.String(), C_WHOIS, C_BACKGROUND, F_SERVER); PostActive (&display); } return true; case RPL_WHOWASUSER: // 314 { BString theNick (GetWord (data, 4)), theIdent (GetWord (data, 5)), theAddress (GetWord (data, 6)), theName (RestOfString (data, 8)), tempString ("[x] "); theName.RemoveFirst (":"); tempString += B_TRANSLATE("%1 was (%2)"); tempString.ReplaceFirst("%1", theNick); BString nickString = theIdent << "@" << theAddress; tempString.ReplaceFirst("%2", nickString.String()); tempString += "\n"; BMessage msg (M_DISPLAY); PackDisplay (&msg, tempString.String(), C_WHOIS, C_BACKGROUND, F_SERVER); PostActive (&msg); } return true; case RPL_WHOISIDLE: // 317 { BString theNick (GetWord (data, 4)), tempString ("[x] "), tempString2 ("[x] "), theTime (GetWord (data, 5)), signOnTime (GetWord (data, 6)); int64 idleTime (strtoul(theTime.String(), NULL, 0)); tempString += B_TRANSLATE("Idle"); tempString += ": "; tempString += DurationString(idleTime * 1000 * 1000); tempString += "\n"; int32 serverTime = strtoul(signOnTime.String(), NULL, 0); struct tm ptr; time_t st; 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 += B_TRANSLATE("Signon"); tempString2 += ": "; tempString2 += signOnTimeParsed; tempString2 += "\n"; BMessage msg (M_DISPLAY); PackDisplay (&msg, tempString.String(), C_WHOIS, C_BACKGROUND, F_SERVER); PostActive (&msg); PackDisplay (&msg, tempString2.String(), C_WHOIS, C_BACKGROUND, F_SERVER); PostActive (&msg); } return true; case RPL_ENDOFWHOIS: // 318 case RPL_ENDOFNAMES: // 366 case RPL_ENDOFWHOWAS: // 369 { // nothing } return true; case RPL_WHOISCHANNELS: // 319 { BString theChannels (RestOfString (data, 5)); theChannels.RemoveFirst(":"); BMessage display (M_DISPLAY); BString buffer = "[x] "; buffer += B_TRANSLATE("Channels"); buffer += ": "; buffer += theChannels; buffer += "\n"; PackDisplay (&display, buffer.String(), C_WHOIS, C_BACKGROUND, F_SERVER); PostActive (&display); } return true; case RPL_LISTSTART: // 321 { BMessage msg (M_LIST_BEGIN); if (fListAgent) vision_app->pClientWin()->DispatchMessage(&msg, (BView *)fListAgent); } return true; case RPL_LIST: // 322 { BMessage msg (M_LIST_EVENT); BString channel (GetWord (data, 4)), 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()); if (fListAgent) vision_app->pClientWin()->DispatchMessage(&msg, (BView *)fListAgent); } return true; case RPL_LISTEND: // 323 { BMessage msg (M_LIST_DONE); if (fListAgent) vision_app->pClientWin()->DispatchMessage(&msg, (BView *)fListAgent); } return true; case RPL_CHANNELMODEIS: // 324 { BString theChan (GetWord (data, 4)), theMode (GetWord (data, 5)), tempStuff (RestOfString (data, 6)); if (tempStuff != "-9z99") { theMode.Append(" "); theMode.Append(tempStuff); // avoid extra space w/o params } ClientAgent *aClient (ActiveClient()), *theClient (Client (theChan.String())); BString tempString("*** "); tempString += B_TRANSLATE("Channel mode for %1: %2"); tempString.ReplaceFirst("%1", theChan.String()); tempString.ReplaceFirst("%2", theMode.String()); tempString += '\n'; BMessage msg (M_CHANNEL_MODES); msg.AddString ("msgz", tempString.String()); msg.AddString ("chan", theChan.String()); msg.AddString ("mode", theMode.String()); if (theClient) theClient->fMsgr.SendMessage (&msg); else if (aClient) aClient->fMsgr.SendMessage (&msg); else Display (tempString.String(), C_OP); } return true; case RPL_CHANNELMLOCK: // 325 { BString theChan (GetWord (data, 4)), mLock (GetWord (data, 8)), lockMessage ("*** "); lockMessage += B_TRANSLATE("Channel mode lock for %1: %2"); lockMessage.ReplaceFirst("%1", theChan); lockMessage.ReplaceFirst("%2", mLock); lockMessage += "\n"; BMessage display (M_DISPLAY); PackDisplay (&display, lockMessage.String(), C_OP, C_BACKGROUND, F_TEXT); ClientAgent *theClient (Client (theChan.String())); if (theClient) theClient->fMsgr.SendMessage (&display); else 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; time_t st; 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 = B_TRANSLATE("Channel %1 was created at %2"); tempString.ReplaceFirst("%1", theChan); tempString.ReplaceFirst("%2", theTimeParsed); tempString += '\n'; Display (tempString.String()); } return true; case RPL_NOTOPIC: // 331 { BString theChan (GetWord (data, 4)), tempString ("[x] "); tempString += B_TRANSLATE("No topic set in %1"); tempString.ReplaceFirst("%1", theChan); tempString += '\n'; BMessage msg (M_DISPLAY); PackDisplay (&msg, tempString.String(), C_ERROR); PostActive (&msg); } return true; case RPL_TOPIC: // 332 { BString theChannel (GetWord (data, 4)), theTopic (RestOfString (data, 5)); ClientAgent *client (Client (theChannel.String())); theTopic.RemoveFirst (":"); if (client) { BMessage display (M_DISPLAY); BString buffer; buffer += "*** "; buffer += B_TRANSLATE("Topic: %1"); buffer.ReplaceFirst("%1", theTopic); buffer += '\n'; PackDisplay (&display, buffer.String(), C_WHOIS); BMessage msg (M_CHANNEL_TOPIC); msg.AddString ("topic", theTopic.String()); msg.AddMessage ("display", &display); if (client->fMsgr.IsValid()) client->fMsgr.SendMessage (&msg); } } 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; time_t st; 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) { BMessage display (M_DISPLAY); BString buffer = "*** "; buffer += B_TRANSLATE("Topic set by %1 at %2"); buffer.ReplaceFirst("%1", user); buffer.ReplaceFirst("%2", theTimeParsed); buffer += '\n'; PackDisplay (&display, buffer.String(), C_WHOIS); if (client->fMsgr.IsValid()) client->fMsgr.SendMessage (&display); } } return true; case RPL_INVITING: // 341 { BString channel (GetWord (data, 5)), theNick (GetWord (data, 4)), tempString; tempString += "*** "; tempString += B_TRANSLATE("%1 has been invited to %2."); tempString.ReplaceFirst("%1", theNick); tempString.ReplaceFirst("%2", channel); tempString += "\n"; BMessage display (M_DISPLAY); PackDisplay (&display, tempString.String(), C_WHOIS); PostActive (&display); } return true; case RPL_NAMEREPLY: // 353 { BString channel (GetWord (data, 5)), names (RestOfString (data, 6)); ClientAgent *client (Client (channel.String())); names.RemoveFirst (":"); BString tempString ("*** "); tempString += B_TRANSLATE("Users in %1: %2"); tempString.ReplaceFirst("%1", channel); tempString.ReplaceFirst("%2", names); tempString += '\n'; Display (tempString.String(), C_TEXT); if (client) // in the channel { BMessage msg (M_CHANNEL_NAMES); BString nick; int32 place (1); while ((nick = GetWord (names.String(), place)) != "-9z99") { const char *sNick (nick.String()); bool founder (false), protect (false), op (false), voice (false), helper (false), ignored; if (nick[0] == '*') { ++sNick; founder = true; } else if (nick[0] == '!') { ++sNick; protect = true; } else if (nick[0] == '@') { ++sNick; op = true; } else if (nick[0] == '+') { ++sNick; voice = true; } else if (nick[0] == '%') { ++sNick; helper = true; } ignored = false; // BMessage aMsg (M_IS_IGNORED), reply; // aMsg.AddString ("server", fServerName.String()); // aMsg.AddString ("nick", sNick); // be_app_messenger.SendMessage (&aMsg, &reply); // reply.FindBool ("ignored", &ignored); msg.AddString ("nick", nick.String()); msg.AddBool ("founder", founder); msg.AddBool ("protect", protect); msg.AddBool ("op", op); msg.AddBool ("voice", voice); msg.AddBool ("helper", helper); msg.AddBool ("ignored", ignored); ++place; } if (client->fMsgr.IsValid()) client->fMsgr.SendMessage (&msg); } } return true; case RPL_MOTD: // 372 case RPL_MOTDALT: // 378 case RPL_OPERMOTDSTART: // 609 case RPL_OPERMOTD: // 610 case RPL_OPERENDOFMOTD: // 611 { BString tempString (RestOfString(data, 4)); tempString.RemoveFirst (":"); tempString.Append ("\n"); Display (tempString.String(), C_SERVER, C_BACKGROUND, F_SERVER); } return true; case RPL_MOTDSTART: // 375 { BString tempString ("- "); tempString += B_TRANSLATE("Server Message Of the Day"); tempString += ":\n"; Display (tempString.String(), C_SERVER, C_BACKGROUND, F_SERVER); } return true; case RPL_ENDOFMOTD: // 376 case ERR_NOMOTD: // 422 { BString tempString (RestOfString (data, 4)); tempString.RemoveFirst (":"); tempString.Append ("\n"); Display (tempString.String(), C_SERVER, C_BACKGROUND, F_SERVER); if (fInitialMotd && fCmds.Length()) { BMessage msg (M_SUBMIT_INPUT); const char *place (fCmds.String()), *eol; msg.AddInt32 ("which", PASTE_MULTI_NODELAY); while ((eol = strchr (place, '\n')) != 0) { BString line; line.Append (place, eol - place); msg.AddString ("data", line.String()); ParseAutoexecChans (line); place = eol + 1; } if (*place) { // check in case this was the only line ParseAutoexecChans (BString(place)); msg.AddString ("data", place); } msg.AddInt32 ("which", 3); msg.AddBool ("autoexec", true); fMsgr.SendMessage (&msg); } BString IPCommand ("/userhost "); IPCommand += fMyNick; ParseCmd (IPCommand.String()); if (fReconnecting) { BString reString = "[@] "; reString += B_TRANSLATE("Successful reconnect"); reString += "\n"; Display (reString.String(), C_ERROR); DisplayAll (reString.String(), C_ERROR, C_BACKGROUND, F_SERVER); fMsgr.SendMessage (M_REJOIN_ALL); fReconnecting = false; } fInitialMotd = false; } return true; case RPL_USERSSTART: // 392 { // empty for now } return true; case RPL_USERS: // 393 { // empty for now } return true; case ERR_ERRONEOUSNICKNAME: // 432 case ERR_NICKNAMEINUSE: // 433 case ERR_RESOURCEUNAVAILABLE: // 437 { BString theNick (GetWord (data, 4)); if (fIsConnecting) { BString nextNick (GetNextNick()); if (nextNick != "") { BString tempString = "* "; tempString += B_TRANSLATE("Nickname \"%1\" in use or unavailable, trying \"%2\""); tempString.ReplaceFirst("%1", theNick.String()); tempString.ReplaceFirst("%2", nextNick.String()); tempString += "\n"; Display (tempString.String()); tempString = "NICK "; tempString += nextNick; SendData (tempString.String()); return true; } else { BString tempString = "* "; tempString += B_TRANSLATE("All your pre-selected nicknames are in use."); tempString += "\n"; Display (tempString.String()); tempString = "* "; tempString += B_TRANSLATE("Please type /NICK <NEWNICK> to try another."); tempString += "\n"; Display (tempString.String()); return true; } } BString tempString = "[x] "; tempString += B_TRANSLATE("Nickname/Channel \"%1\" is already in use or unavailable."); tempString.ReplaceFirst("%1", theNick); tempString += "\n"; BMessage display (M_DISPLAY); PackDisplay (&display, tempString.String(), C_NICK); PostActive (&display); } return true; case ERR_USERNOTINCHANNEL: // 441 { BString theChannel (GetWord (data, 5)), theNick (GetWord (data, 4)), tempString ("[x] "); tempString += B_TRANSLATE("%1 not in %2."); tempString.ReplaceFirst("%1", theNick); tempString.ReplaceFirst("%2", theChannel); tempString += "\n"; BMessage msg (M_DISPLAY); PackDisplay (&msg, tempString.String(), C_ERROR); PostActive (&msg); } return true; case ERR_NOTONCHANNEL: // 442 { BString theChannel (GetWord (data, 4)), tempString ("[x] "); tempString += B_TRANSLATE("You're not in %1."); tempString.ReplaceFirst("%1", theChannel); tempString += "\n"; BMessage msg (M_DISPLAY); PackDisplay (&msg, tempString.String(), C_ERROR); PostActive (&msg); } return true; case ERR_USERONCHANNEL: // 443 { BString theChannel (GetWord (data, 5)), theNick (GetWord (data, 4)), tempString ("[x] "); tempString += B_TRANSLATE("%1 is already in %2."); tempString.ReplaceFirst("%1", theNick); tempString.ReplaceFirst("%2", theChannel); tempString += "\n"; BMessage msg (M_DISPLAY); PackDisplay (&msg, tempString.String(), C_ERROR); PostActive (&msg); } return true; case ERR_KEYSET: // 467 { BString theChannel (GetWord (data, 4)), tempString ("[x] "); tempString += B_TRANSLATE("Channel key already set in %1."); tempString.ReplaceFirst("%1", theChannel); tempString += "\n"; BMessage msg (M_DISPLAY); PackDisplay (&msg, tempString.String(), C_ERROR); PostActive (&msg); } return true; case ERR_UNKNOWNMODE: // 472 { BString theMode (GetWord (data, 4)), tempString ("[x] "); tempString += B_TRANSLATE("Unknown channel mode: '%1'."); tempString.ReplaceFirst("%1", theMode); tempString += "\n"; BMessage msg (M_DISPLAY); PackDisplay (&msg, tempString.String(), C_QUIT); PostActive (&msg); } return true; case ERR_INVITEONLYCHAN: // 473 { BString theChan (GetWord (data, 4)), tempString ("[x] "), theReason (RestOfString (data, 5)); theReason.RemoveFirst(":"); theReason.ReplaceLast("channel", theChan.String()); tempString << theReason < " "; tempString += B_TRANSLATE("(invite only)"); tempString += "\n"; BMessage msg (M_DISPLAY); PackDisplay (&msg, tempString.String(), C_QUIT, C_BACKGROUND, F_SERVER); PostActive (&msg); RemoveAutoexecChan (theChan); } return true; case ERR_BANNEDFROMCHAN: // 474 { BString theChan (GetWord (data, 4)), tempString ("[x] "), theReason (RestOfString (data, 5)); theReason.RemoveFirst(":"); theReason.ReplaceLast("channel", theChan.String()); tempString << theReason < " "; tempString += B_TRANSLATE("(you're banned)"); tempString += "\n"; BMessage msg (M_DISPLAY); PackDisplay (&msg, tempString.String(), C_QUIT, C_BACKGROUND, F_SERVER); PostActive (&msg); RemoveAutoexecChan (theChan); } return true; case ERR_BADCHANNELKEY: // 475 { BString theChan (GetWord(data, 4)), theReason (RestOfString(data, 5)), tempString("[x] "); theReason.RemoveFirst(":"); theReason.ReplaceLast("channel", theChan.String()); tempString << theReason << " "; tempString += B_TRANSLATE("(bad channel key)"); tempString += "\n"; BMessage msg (M_DISPLAY); PackDisplay (&msg, tempString.String(), C_QUIT, C_BACKGROUND, F_SERVER); PostActive (&msg); RemoveAutoexecChan (theChan); } return true; case ERR_UMODEUNKNOWNFLAG: // 501 { BMessage msg (M_DISPLAY); BString buffer = "[x] "; buffer += B_TRANSLATE("Unknown mode flag."); buffer += "\n"; PackDisplay (&msg, buffer.String(), C_QUIT); PostActive (&msg); } return true; // not sure what these numerics are, // but they are usually on-connect messages case RPL_290: // 290 case RPL_291: // 291 case RPL_292: // 292 { BString tempString (RestOfString(data, 4)); tempString.RemoveFirst (":"); tempString.Append ("\n"); tempString.Prepend ("- "); Display (tempString.String()); } return true; case RPL_WHOISREGISTEREDBOT: // 617 { // conflicts with RPL_DCCALLOWCHANGE BString theNick (GetWord (data, 4)), theMessage (RestOfString (data, 5)), tempString; theNick.RemoveFirst (":"); theMessage.RemoveFirst (":"); theMessage.Append ("\n"); switch (fIrcdtype) { case IRCD_ULTIMATE: { tempString += "[@] "; tempString += theMessage; BMessage msg (M_DISPLAY); PackDisplay (&msg, tempString.String(), C_WHOIS, C_BACKGROUND, F_SERVER); PostActive (&msg); } break; default: { tempString += theNick; tempString += " "; tempString += theMessage; Display (tempString.String()); } } } return true; default: break; } return false; }
status_t BUrl::_ParseAndSplit() { // proto:[//]user:pass@host:port/path int32 v; BString left; v = FindFirst(":"); if (v < 0) return B_BAD_VALUE; // TODO: proto and host should be lowercased. // see http://en.wikipedia.org/wiki/URL_normalization CopyInto(fProto, 0, v); CopyInto(left, v + 1, Length() - v); // TODO: RFC1738 says the // part should indicate the uri follows the // u:p@h:p/path convention, so it should be used to check for special cases. if (left.FindFirst("//") == 0) left.RemoveFirst("//"); fFull = left; // path part // actually some apps handle file://[host]/path // but I have no idea what proto it implies... // or maybe it's just to emphasize on "localhost". v = left.FindFirst("/"); if (v == 0 || fProto == "file") { fPath = left; return B_OK; } // some protos actually implies path if it's the only component if ((v < 0) && (fProto == "beshare" || fProto == "irc")) { fPath = left; return B_OK; } if (v > -1) { left.MoveInto(fPath, v+1, left.Length()-v); left.Remove(v, 1); } // user:pass@host v = left.FindFirst("@"); if (v > -1) { left.MoveInto(fUser, 0, v); left.Remove(0, 1); v = fUser.FindFirst(":"); if (v > -1) { fUser.MoveInto(fPass, v, fUser.Length() - v); fPass.Remove(0, 1); } } else if (fProto == "finger") { // single component implies user // see also: http://www.subir.com/lynx/lynx_help/lynx_url_support.html fUser = left; return B_OK; } // host:port v = left.FindFirst(":"); if (v > -1) { left.MoveInto(fPort, v + 1, left.Length() - v); left.Remove(v, 1); } // not much left... fHost = left; return B_OK; }
void SourceFileC::UpdateDependencies(BuildInfo &info) { BString abspath = GetPath().GetFullPath(); if (abspath[0] != '/') { abspath.Prepend("/"); abspath.Prepend(info.projectFolder.GetFullPath()); } BString command; if (gUseFastDep && gFastDepAvailable) command << "fastdep " << info.includeString << " '" << abspath.String() << "'"; else command << "gcc -MM " << info.includeString << " '" << abspath.String() << "'"; BString depstr; RunPipedCommand(command.String(), depstr, true); STRACE(1,("Update Dependencies for %s\nCommand:%s\nOutput:%s\n", GetPath().GetFullPath(),command.String(),depstr.String())); if (gUseFastDep && gFastDepAvailable) { if (depstr.FindFirst("error ") == 0) { int32 index, startpos = 0; index = depstr.FindFirst("error ", startpos); while (index >= 0) { startpos = index + 6; index = depstr.FindFirst("error ", startpos); } index = depstr.FindFirst("\n") + 1; depstr = depstr.String() + index; } // The first part of the dependency string should be FileName.o: int32 secondlinepos = depstr.FindFirst("\n") + 1; BString tempstr = depstr; depstr = tempstr.String() + secondlinepos; depstr.ReplaceAll(" \\\n\t","|"); if (depstr.FindLast("\n") == depstr.CountChars() - 1) depstr.RemoveLast("\n"); if (depstr.FindFirst(" ") == 0) depstr.RemoveFirst(" "); fDependencies = depstr; } else { // The reason that all of this works is because the absolute paths force // each file to be on a separate line. Going with relative paths is FAR more // of a headache than I want to mess with. Bleah. if (depstr.FindFirst(" warning: ") >= 0) { int32 index, startpos = 0; index = depstr.FindFirst(" warning: ", startpos); while (index >= 0) { startpos = index + 10; index = depstr.FindFirst(" warning: ", startpos); } index = depstr.FindFirst("\n") + 1; depstr = depstr.String() + index; } // The first part of the dependency string should be FileName.o: BString objfilename = GetPath().GetBaseName(); objfilename << ".o: "; int32 filenamepos = depstr.FindFirst(objfilename.String()); if (filenamepos == 0) { int32 lineend = depstr.FindFirst("\n",filenamepos); if (lineend >= 0) fDependencies = depstr.String() + lineend + 2; } else fDependencies = depstr.String(); fDependencies.RemoveSet("\\\n"); fDependencies.ReplaceAll(" ","|"); fDependencies.ReplaceAll("| ","|"); if (fDependencies[0] == ' ') fDependencies.RemoveFirst(" "); } }
void Project::Save(const char *path) { BString projectPath = fPath.GetFolder(); projectPath << "/"; BString data; data << "NAME=" << fName << "\nTARGETNAME=" << fTargetName << "\n"; data << "PLATFORM=" << sPlatformArray[fPlatform] << "\n"; switch (fSCMType) { case SCM_HG: { data << "SCM=hg\n"; break; } case SCM_GIT: { data << "SCM=git\n"; break; } case SCM_SVN: { data << "SCM=svn\n"; break; } case SCM_NONE: { data << "SCM=none\n"; break; } default: { break; } } for (int32 i = 0; i < CountGroups(); i++) { SourceGroup *group = GroupAt(i); data << "GROUP=" << group->name << "\n"; data << "EXPANDGROUP=" << (group->expanded ? "yes" : "no") << "\n"; for (int32 j = 0; j < group->filelist.CountItems(); j++) { SourceFile *file = group->filelist.ItemAt(j); BString temppath(file->GetPath().GetFullPath()); if (temppath.FindFirst(projectPath.String()) == 0) { // Absolute paths which include the project folder are stripped // down into relative paths temppath.RemoveFirst(projectPath.String()); } data << "SOURCEFILE=" << temppath << "\n"; if (file->GetDependencies() && strlen(file->GetDependencies()) > 0) data << "DEPENDENCY=" << file->GetDependencies() << "\n"; } } for (int32 i = 0; i < fLocalIncludeList.CountItems(); i++) data << "LOCALINCLUDE=" << fLocalIncludeList.ItemAt(i)->Relative() << "\n"; for (int32 i = 0; i < fSystemIncludeList.CountItems(); i++) { BString *string = fSystemIncludeList.ItemAt(i); BString include = *string; if (include[0] == '/') include.RemoveFirst(projectPath.String()); data << "SYSTEMINCLUDE=" << include << "\n"; } for (int32 i = 0; i < fLibraryList.CountItems(); i++) { SourceFile *file = (SourceFile*)fLibraryList.ItemAt(i); if (!file) continue; BString strpath(file->GetPath().GetFullPath()); if (gPlatform == PLATFORM_ZETA) { if (strpath.FindFirst("/boot/beos/etc/develop/zeta-r1-gcc2-x86/") == 0) strpath.ReplaceFirst("/boot/beos/etc/develop/zeta-r1-gcc2-x86/", "/boot/develop/"); } if (strpath.FindFirst(projectPath.String()) == 0) strpath.RemoveFirst(projectPath.String()); data << "LIBRARY=" << strpath.String() << "\n"; } data << "RUNARGS=" << fRunArgs << "\n"; data << "CCDEBUG=" << (fDebug ? "yes" : "no") << "\n"; data << "CCPROFILE=" << (fProfile ? "yes" : "no") << "\n"; data << "CCOPSIZE=" << (fOpSize ? "yes" : "no") << "\n"; data << "CCOPLEVEL=" << (int)fOpLevel << "\n"; data << "CCTARGETTYPE=" << fTargetType << "\n"; data << "CCEXTRA=" << fExtraCompilerOptions << "\n"; data << "LDEXTRA=" << fExtraLinkerOptions << "\n"; BFile file(path,B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); if (file.InitCheck() != B_OK) { STRACE(2,("Couldn't create project file %s. Bailing out\n",path)); return; } STRACE(2,("Saved Project %s. Data as follows:\n%s\n",path,data.String())); file.Write(data.String(),data.Length()); fPath = path; fObjectPath = fPath.GetFolder(); BString objfolder("(Objects."); objfolder << GetName() << ")"; fObjectPath.Append(objfolder.String()); BNodeInfo nodeInfo(&file); nodeInfo.SetType(PROJECT_MIME_TYPE); UpdateBuildInfo(); }
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 }