char * ICQAPI ishare_makeControlFilePath(ISHARED_CONFIG *cfg, char *buffer) { char *ptr; loadString(cfg, "workfiles", "", buffer, 0x7F); if(!*buffer) queryPath(cfg,"ishare.tmp",buffer,0x7F); ptr = buffer+strlen(buffer); #ifdef linux if(*(ptr-1) != '/') *(ptr++) = '/'; #else if(*(ptr-1) != '\\') *(ptr++) = '\\'; #endif return ptr; }
App::App() : BApplication(APP_SIG) { // build gIgnoreList as a list of BDirectory objects find_directory(B_USER_SETTINGS_DIRECTORY, &gSettingsPath, true); gSettingsPath.Append(kSettingsDir); BPath ignorePath(gSettingsPath); ignorePath.Append(kIgnoreDir); BDirectory ignoreDir(ignorePath.Path()); if (ignoreDir.InitCheck() == B_OK) { entry_ref ref; while (ignoreDir.GetNextRef(&ref) == B_OK) { BEntry target(&ref, true); // BEntry resolution for symlink resolution entry_ref ignore; target.GetRef(&ignore); gIgnoreList.push_back(ignore); } } // You can't symlink to Trash, so the path is hard-coded entry_ref trash; if (get_ref_for_path("/boot/home/Desktop/Trash", &trash) == B_OK) { gIgnoreList.push_back(trash); } // this stuff needs to die BPath queryPath(gSettingsPath); queryPath.Append(kQueryDir); BDirectory queryDir(queryPath.Path()); bool showError = false; if ( queryDir.InitCheck() == B_OK ) { int32 ctr; int32 entries = queryDir.CountEntries(); query_load_info* loadInfo = new query_load_info[ entries ]; for( ctr=0; ctr<entries; ctr++) { queryDir.GetNextRef( &(loadInfo[ctr].ref) ); BFile file(&(loadInfo[ctr].ref), B_READ_ONLY); if( file.InitCheck() != B_OK ) { showError = true; break; } attr_info ainfo; if( file.GetAttrInfo("_trk/qrystr", &ainfo) != B_OK ) { showError = true; break; } loadInfo[ctr].predicate = new char[ainfo.size+1]; if( file.ReadAttr("_trk/qrystr", B_STRING_TYPE, 0, (void*) loadInfo[ctr].predicate, ainfo.size) <= 0 ) { showError = true; break; } #ifdef DEBUG BeDC dc("QueryWatcher"); BString str; str<<loadInfo[ctr].ref.name<<" r-side: "<<be_plain_font->StringWidth(loadInfo[ctr].ref.name)+30; dc.SendMessage( str.String() ); #endif loadInfo[ctr].rect.Set(0, ctr*16, be_plain_font->StringWidth(loadInfo[ctr].ref.name)+30, (ctr+1)*16); } if( ctr == 0 ) showError = true; else { //find largest right-hand side of rect float r=0; for(int i=0; i<ctr; i++) { if( loadInfo[i].rect.right > r ) r = loadInfo[i].rect.right; } #ifdef DEBUG BeDC dc("QueryWatcher"); BString str; str<<"Largest r-side: "<<r; dc.SendMessage( str.String() ); #endif Window* win = new Window( BRect(100,100, r + 107, ((ctr)*16) + 107 )); for( int32 loadCtr=0; loadCtr<ctr; loadCtr++) win->AddQuery( loadInfo[loadCtr].ref, loadInfo[loadCtr].predicate, loadInfo[loadCtr].rect ); win->Show(); } delete [] loadInfo; } else showError = true; if( showError ) { BAlert* alert = new BAlert("Missing Queries", "No Tracker query files were found.\nIf this is your first time running QueryWatcher,\nsorry for the kludge, but you'd better read\nthe documentation first.", "Lame", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); alert->Go(); BMessenger(this).SendMessage(B_QUIT_REQUESTED); } }