static int CreateGroup(WPARAM wParam,LPARAM lParam) { int newId=CountGroups(); TCHAR newBaseName[127], newName[128]; char str[33]; int i; DBVARIANT dbv; if(wParam) { itoa(wParam-1,str,10); if (DBGetContactSettingTString(NULL, "CListGroups", str, &dbv)) return 0; mir_sntprintf( newBaseName, SIZEOF(newBaseName), _T("%s\\%s"), dbv.pszVal + 1, TranslateT("New Group")); mir_free(dbv.pszVal); } else lstrcpyn( newBaseName, TranslateT( "New Group" ), SIZEOF( newBaseName )); itoa(newId,str,10); i=1; lstrcpyn( newName + 1, newBaseName, SIZEOF(newName) - 1); while(GroupNameExists(newName+1,-1)) mir_sntprintf( newName + 1, SIZEOF(newName) - 1, _T("%s (%d)"), newBaseName, ++i ); newName[0]=1|GROUPF_EXPANDED; //1 is required so we never get '\0' DBWriteContactSettingTString(NULL, "CListGroups", str, newName); CallService(MS_CLUI_GROUPADDED,newId+1,1); return newId+1; }
int32 Project::CountFiles(void) { int32 count = 0; for (int32 i = 0; i < CountGroups(); i++) count += GroupAt(i)->filelist.CountItems(); return count; }
void Project::ForceRebuild(void) { STRACE(1,("%s: Force rebuild\n",GetName())); 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); file->RemoveObjects(fBuildInfo); } } }
void Project::SortDirtyList(void) { 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 (IsFileDirty(file)) { MakeFileClean(file); MakeFileDirty(file); } } } }
void Project::RemoveGroup(SourceGroup *group, bool remove_members) { if (!group || CountGroups() <= 1) return; STRACE(1,("%s::RemoveGroup %s,%s\n",GetName(),group->name.String(),remove_members ? "true" : "false")); if (remove_members) { while (group->filelist.CountItems() > 0) { SourceFile *file = group->filelist.RemoveItemAt(0L); RemoveFile(file); } } fGroupList.RemoveItem(group); }
SourceFile * Project::FindFile(const char *path) { if (!path) return NULL; for (int32 i = 0; i < CountGroups(); i++) { SourceGroup *group = GroupAt(i); for (int32 j = 0; j < group->filelist.CountItems(); j++) { SourceFile *src = group->filelist.ItemAt(j); if (src && strcmp(src->GetPath().GetFullPath(),path) == 0) return src; } } return NULL; }
void Project::UpdateResources(void) { DPath targetpath(fPath.GetFolder()); targetpath.Append(GetTargetName()); BString resFileString; int32 resCount = 0; 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->GetResourcePath(fBuildInfo).GetFullPath()) { resFileString << "'" << file->GetResourcePath(fBuildInfo).GetFullPath() << "' "; resCount++; } } } if (resCount > 0) { BString resString = "xres -o "; resString << "'" << targetpath.GetFullPath() << "' " << resFileString; BString errmsg; PipeCommand(resString.String(),errmsg); STRACE(1,("Resources for %s:\n%s\nErrors:%s\n",GetName(),resString.String(),errmsg.String())); if (errmsg.CountChars() > 0) printf("Resource errors: %s\n",errmsg.String()); } else { STRACE(1,("Resources for %s: No resource files to add\n",GetName())); } }
bool Project::HasFileName(const char *name) { if (!name) return false; DPath newfile(name); for (int32 i = 0; i < CountGroups(); i++) { SourceGroup *group = GroupAt(i); for (int32 j = 0; j < group->filelist.CountItems(); j++) { SourceFile *src = group->filelist.ItemAt(j); if (src && strcmp(src->GetPath().GetFileName(),newfile.GetFileName()) == 0) return true; } } return false; }
void Project::RemoveFile(SourceFile *file) { if (!file) { STRACE(2,("%s:Remove File: NULL file in call\n",GetName())); return; } for (int32 i = 0; i < CountGroups(); i++) { SourceGroup *group = GroupAt(i); if (group->filelist.HasItem(file)) { file->RemoveObjects(fBuildInfo); group->filelist.RemoveItem(file); STRACE(2,("%s:Remove File: Removed file %s\n",GetName(),file->GetPath().GetFullPath())); } } }
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 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(); }
void GroupListEmoticons::Load() { selection = -1; // Load fonts groupFont = mir_font_get(_T("Emoticons"), _T("Group Name"), &groupColor); emoticonFont = mir_font_get(_T("Emoticons"), _T("Emoticons Text"), &emoticonColor); groupBkgColor = mir_color_get(_T("Emoticons"), _T("Group Background")); ssd->background = mir_color_get(_T("Emoticons"), _T("Emoticons Background")); num_groups = CountGroups(); groups = (Group *) malloc(num_groups * sizeof(Group)); char *current_group = ssd->module->emoticons[0]->group; int current_id = -1; int i; for(i = 0; i < ssd->module->emoticons.getCount(); i++) { Emoticon *e = ssd->module->emoticons[i]; if (e->IgnoreFor(ssd->module)) continue; if (stricmp(e->group, current_group) != 0 || i == 0) { if (i != 0) groups[current_id].end = i - 1; current_group = e->group; current_id++; SetGroupName(groups[current_id], current_group); groups[current_id].start = i; groups[current_id].count = 1; } else { groups[current_id].count++; } } groups[current_id].end = i - 1; // First calc the width window.width = 0; for(i = 0; i < num_groups; i++) { Group &group = groups[i]; GetMaxEmoticonSize(group); group.cols = GetNumOfCols(group.count); if (group.name[0] != _T('\0')) { RECT rc = CalcRect(group.name, groupFont); window.width = max(window.width, rc.right - rc.left + 2 * BORDER + 1); } window.width = max(window.width, group.max_width * group.cols + (group.cols + 1) * BORDER); } // Now calc the height window.height = 0; for(i = 0; i < num_groups; i++) { Group &group = groups[i]; group.top = window.height; int w = window.width - BORDER; // Recalc the num of cols group.lines = GetNumOfLines(group.count, group.cols); int new_cols = w / (group.max_width + BORDER); int new_lines = GetNumOfLines(group.count, new_cols); if (new_lines < group.lines) { group.cols = new_cols; group.lines = new_lines; } // If there is space left, put it into the emoticons group.max_width += (w - group.cols * (group.max_width + BORDER)) / group.cols; if (group.name[0] != '\0') { RECT rc = CalcRect(group.name, groupFont); window.height += HeightWithBorders(rc); } window.height += group.max_height * group.lines + (group.lines + 1) * BORDER; } }