void BaseCheckoutWizardPage::slotRefreshBranches() { if (!isBranchSelectorVisible()) return; // Refresh branch list on demand. This is hard to make // automagically since there can be network slowness/timeouts, etc. int current; const QStringList branchList = branches(repository(), ¤t); d->ui.branchComboBox->clear(); d->ui.branchComboBox->setEnabled(branchList.size() > 1); if (!branchList.isEmpty()) { d->ui.branchComboBox->addItems(branchList); if (current >= 0 && current < branchList.size()) d->ui.branchComboBox->setCurrentIndex(current); } slotChanged(); }
int CTGitPathList::FillBasedOnIndexFlags(unsigned short flag, CTGitPathList* list /*nullptr*/) { Clear(); CTGitPath path; CAutoRepository repository(g_Git.GetGitRepository()); if (!repository) return -1; CAutoIndex index; if (git_repository_index(index.GetPointer(), repository)) return -1; int count; if (list == nullptr) count = 1; else count = list->GetCount(); for (int j = 0; j < count; ++j) { for (size_t i = 0, ecount = git_index_entrycount(index); i < ecount; ++i) { const git_index_entry *e = git_index_get_byindex(index, i); if (!e || !((e->flags | e->flags_extended) & flag) || !e->path) continue; CString one = CUnicodeUtils::GetUnicode(e->path); if (!(!list || (*list)[j].GetWinPathString().IsEmpty() || one == (*list)[j].GetGitPathString() || (PathIsDirectory(g_Git.CombinePath((*list)[j].GetWinPathString())) && one.Find((*list)[j].GetGitPathString() + _T("/")) == 0))) continue; //SetFromGit will clear all status path.SetFromGit(one); if ((e->flags | e->flags_extended) & GIT_IDXENTRY_SKIP_WORKTREE) path.m_Action = CTGitPath::LOGACTIONS_SKIPWORKTREE; else if ((e->flags | e->flags_extended) & GIT_IDXENTRY_VALID) path.m_Action = CTGitPath::LOGACTIONS_ASSUMEVALID; AddPath(path); } } RemoveDuplicates(); return 0; }
static OrgKdeCervisia5CvsserviceCvsserviceInterface* StartDBusService(const QString& directory) { // start the cvs D-Bus service QString error; QString appId; if ( KToolInvocation::startServiceByDesktopName("org.kde.cvsservice5", QStringList(), &error, &appId) ) { std::cerr << "Starting cvsservice failed with message: " << error.toLocal8Bit().constData() << std::endl; exit(1); } OrgKdeCervisia5RepositoryInterface repository(appId, "/CvsRepository", QDBusConnection::sessionBus()); repository.setWorkingCopy(directory); // create a reference to the service return new OrgKdeCervisia5CvsserviceCvsserviceInterface(appId, "/CvsService", QDBusConnection::sessionBus()); }
static CvsService_stub* StartDCOPService(const QString& directory) { // start the cvs DCOP service QString error; QCString appId; if( KApplication::startServiceByDesktopName("cvsservice", QStringList(), &error, &appId) ) { std::cerr << "Starting cvsservice failed with message: " << error.latin1() << std::endl; exit(1); } DCOPRef repository(appId, "CvsRepository"); repository.call("setWorkingCopy(QString)", directory); // create a reference to the service return new CvsService_stub(appId, "CvsService"); }
QSharedPointer<VcsBase::AbstractCheckoutJob> CloneWizardPage::createCheckoutJob(QString *checkoutPath) const { const Internal::GitClient *client = Internal::GitPlugin::instance()->gitClient(); const QString workingDirectory = path(); const QString checkoutDir = directory(); *checkoutPath = workingDirectory + QLatin1Char('/') + checkoutDir; const QString binary = client->gitBinaryPath(); VcsBase::ProcessCheckoutJob *job = new VcsBase::ProcessCheckoutJob; const QProcessEnvironment env = client->processEnvironment(); const QString checkoutBranch = branch(); QStringList args(QLatin1String("clone")); if (!checkoutBranch.isEmpty()) args << QLatin1String("--branch") << checkoutBranch; args << repository() << checkoutDir; job->addStep(binary, args, workingDirectory, env); return QSharedPointer<VcsBase::AbstractCheckoutJob>(job); }
static void _processFile(const char* repositoryRoot, const char* xmlFileName) { // Create the parser: Array<char> text; text.reserveCapacity(1024 * 1024); FileSystem::loadFileToMemory(text, xmlFileName); text.append('\0'); XmlParser parser((char*)text.getData()); CIMRepository repository(repositoryRoot); repository.createNameSpace(CIMV2_NAMESPACE); repository.createNameSpace(ROOT_NAMESPACE); // Create the qualifiers: if (!ProcessCimElement(repository, parser)) { cerr << "CIM root element missing" << endl; exit(1); } }
// ReadTree is/must only be executed on an empty list int CGitHeadFileList::ReadTree() { CAutoWriteLock lock(m_SharedMutex); ATLASSERT(empty()); CAutoRepository repository(m_Gitdir); CAutoCommit commit; CAutoTree tree; bool ret = repository; ret = ret && !git_commit_lookup(commit.GetPointer(), repository, (const git_oid*)m_Head.m_hash); ret = ret && !git_commit_tree(tree.GetPointer(), commit); ret = ret && !ReadTreeRecursive(*repository, tree, "", CGitHeadFileList::CallBack, this); if (!ret) { clear(); m_LastModifyTimeHead = 0; return -1; } std::sort(this->begin(), this->end(), SortTree); m_TreeHash = git_commit_id(commit)->id; return 0; }
void RepositoryListItem::setRsh(const QString& rsh) { QString repo = repository(); QString method; if( repo.startsWith(QLatin1String(":pserver:")) ) method = "pserver"; else if( repo.startsWith(QLatin1String(":sspi:")) ) method = "sspi"; else if( repo.contains(':') ) { method = "ext"; if( !rsh.isEmpty() ) { method += " ("; method += rsh; method += ')'; } } else method = "local"; setText(1, method); }
static void _processFile(const char* xmlFileName, const char* nameSpace, const char* repositoryRoot) { // Create the parser: Array<Sint8> text; text.reserve(1024 * 1024); FileSystem::loadFileToMemory(text, xmlFileName); text.append('\0'); XmlParser parser((char*)text.getData()); CIMRepository repository(repositoryRoot); // Need to test if namespace exists before adding it repository.createNameSpace(nameSpace); // Put the file in the repository: if (!ProcessCimElement(repository, parser)) { cerr << "CIM root element missing" << endl; exit(1); } }
void GitRepository::branch(const QString& name) { git_repository* repo = repository(); git_auto<git_reference> branch; int err = git_branch_lookup(&branch, repo, name.toLatin1(), GIT_BRANCH_LOCAL); if (err == GIT_ENOTFOUND){ git_oid parent_id; git_auto<git_commit> parent; git_eval(git_reference_name_to_id(&parent_id, repo, "HEAD")); git_eval(git_commit_lookup(&parent, repo, &parent_id)); git_eval(git_branch_create(&branch, repo, name.toLocal8Bit(), parent, 1)); }else{ git_eval(err); } git_eval(git_repository_set_head(repo, git_reference_name(branch))); git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; opts.checkout_strategy = GIT_CHECKOUT_FORCE; git_eval(git_checkout_head(repo, &opts)); }
bool SQLiteDocumentDAO::save(Document::Ptr pub) { if(!pub) { return false; } QueryExecutor executor(database()); QueryParameters params; if(pub->journal()) { Journal::Ptr realJournal = repository()->journalDAO()->findByName(pub->journal()->name(), true); if(realJournal != pub->journal()) { Journal::Ptr old = pub->journal(); pub->setJournal(realJournal); delete old; } } params.insert("title", pub->title()); params.insert("abstract", pub->abstract()); params.insert("year", pub->year()); params.insert("month", pub->month()); params.insert("conference", pub->conference()); params.insert("publisher", pub->publisher()); params.insert("volume", pub->volume()); params.insert("number", pub->number()); params.insert("url", pub->url()); params.insert("doi", pub->doi()); params.insert("isbn", pub->isbn()); params.insert("localURL", pub->localUrl()); params.insert("type", static_cast<uint>(pub->type())); params.insert("isPublished", pub->isPublished()); params.insert("isPeerReviewed", pub->isPeerReviewed()); //params.insert("keywords", pub->keywords()); params.insert("series", pub->series()); params.insert("subTitle", pub->subTitle()); params.insert("pages", pub->pages().toString()); params.insert("authors", StringUtils::serialize(pub->authors())); params.insert("editors", StringUtils::serialize(pub->editors())); params.insert("citeKey", pub->citeKey()); if(pub->journal()) { params.insert("journalId", pub->journal()->id()); } else { params.insert("journalId", QVariant()); } bool ok = executor.insert("document", params); if(ok) { qulonglong id = executor.lastInsertID(); pub->setId(id); repository()->publications()->insert(id, pub); emit dataChanged(); } return ok; }
LRESULT CMainWindow::DoCommand(int id, LPARAM lParam) { switch (id) { case ID_FILE_OPEN: { if (OpenDialog()) { picWindow1.SetPic(leftpicpath, L"", true); picWindow2.SetPic(rightpicpath, L"", false); if (bOverlap) { picWindow1.SetSecondPic(picWindow2.GetPic(), rightpictitle, rightpicpath); } else { picWindow1.SetSecondPic(); } RECT rect; GetClientRect(*this, &rect); PositionChildren(&rect); picWindow1.FitImageInWindow(); picWindow2.FitImageInWindow(); } } break; case ID_VIEW_IMAGEINFO: { bShowInfo = !bShowInfo; HMENU hMenu = GetMenu(*this); UINT uCheck = MF_BYCOMMAND; uCheck |= bShowInfo ? MF_CHECKED : MF_UNCHECKED; CheckMenuItem(hMenu, ID_VIEW_IMAGEINFO, uCheck); picWindow1.ShowInfo(bShowInfo); picWindow2.ShowInfo(bShowInfo); picWindow3.ShowInfo(bShowInfo); // change the state of the toolbar button TBBUTTONINFO tbi; tbi.cbSize = sizeof(TBBUTTONINFO); tbi.dwMask = TBIF_STATE; tbi.fsState = bShowInfo ? TBSTATE_CHECKED | TBSTATE_ENABLED : TBSTATE_ENABLED; SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_IMAGEINFO, (LPARAM)&tbi); } break; case ID_VIEW_OVERLAPIMAGES: { bOverlap = !bOverlap; HMENU hMenu = GetMenu(*this); UINT uCheck = MF_BYCOMMAND; uCheck |= bOverlap ? MF_CHECKED : MF_UNCHECKED; CheckMenuItem(hMenu, ID_VIEW_OVERLAPIMAGES, uCheck); uCheck |= ((m_BlendType == CPicWindow::BLEND_ALPHA) && bOverlap) ? MF_CHECKED : MF_UNCHECKED; CheckMenuItem(hMenu, ID_VIEW_BLENDALPHA, uCheck); UINT uEnabled = MF_BYCOMMAND; uEnabled |= bOverlap ? MF_ENABLED : MF_DISABLED | MF_GRAYED; EnableMenuItem(hMenu, ID_VIEW_BLENDALPHA, uEnabled); // change the state of the toolbar button TBBUTTONINFO tbi; tbi.cbSize = sizeof(TBBUTTONINFO); tbi.dwMask = TBIF_STATE; tbi.fsState = bOverlap ? TBSTATE_CHECKED | TBSTATE_ENABLED : TBSTATE_ENABLED; SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_OVERLAPIMAGES, (LPARAM)&tbi); tbi.fsState = ((m_BlendType == CPicWindow::BLEND_ALPHA) && bOverlap) ? TBSTATE_CHECKED : 0; if (bOverlap) tbi.fsState |= TBSTATE_ENABLED; else tbi.fsState = 0; SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_BLENDALPHA, (LPARAM)&tbi); if (bOverlap) tbi.fsState = 0; else tbi.fsState = bVertical ? TBSTATE_ENABLED | TBSTATE_CHECKED : TBSTATE_ENABLED; SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_ARRANGEVERTICAL, (LPARAM)&tbi); if (bOverlap) { bLinkedPositions = true; picWindow1.LinkPositions(bLinkedPositions); picWindow2.LinkPositions(bLinkedPositions); tbi.fsState = TBSTATE_CHECKED; } else tbi.fsState = bLinkedPositions ? TBSTATE_ENABLED | TBSTATE_CHECKED : TBSTATE_ENABLED; SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_LINKIMAGESTOGETHER, (LPARAM)&tbi); ShowWindow(picWindow2, bOverlap ? SW_HIDE : SW_SHOW); if (bOverlap) { picWindow1.StopTimer(); picWindow2.StopTimer(); picWindow1.SetSecondPic(picWindow2.GetPic(), rightpictitle, rightpicpath, picWindow2.GetHPos(), picWindow2.GetVPos()); picWindow1.SetBlendAlpha(m_BlendType, 0.5f); } else { picWindow1.SetSecondPic(); } picWindow1.SetOverlapMode(bOverlap); picWindow2.SetOverlapMode(bOverlap); RECT rect; GetClientRect(*this, &rect); PositionChildren(&rect); return 0; } break; case ID_VIEW_BLENDALPHA: { if (m_BlendType == CPicWindow::BLEND_ALPHA) m_BlendType = CPicWindow::BLEND_XOR; else m_BlendType = CPicWindow::BLEND_ALPHA; HMENU hMenu = GetMenu(*this); UINT uCheck = MF_BYCOMMAND; uCheck |= ((m_BlendType == CPicWindow::BLEND_ALPHA) && bOverlap) ? MF_CHECKED : MF_UNCHECKED; CheckMenuItem(hMenu, ID_VIEW_BLENDALPHA, uCheck); UINT uEnabled = MF_BYCOMMAND; uEnabled |= bOverlap ? MF_ENABLED : MF_DISABLED | MF_GRAYED; EnableMenuItem(hMenu, ID_VIEW_BLENDALPHA, uEnabled); // change the state of the toolbar button TBBUTTONINFO tbi; tbi.cbSize = sizeof(TBBUTTONINFO); tbi.dwMask = TBIF_STATE; tbi.fsState = ((m_BlendType == CPicWindow::BLEND_ALPHA) && bOverlap) ? TBSTATE_CHECKED | TBSTATE_ENABLED : TBSTATE_ENABLED; SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_BLENDALPHA, (LPARAM)&tbi); picWindow1.SetBlendAlpha(m_BlendType, picWindow1.GetBlendAlpha()); PositionChildren(); } break; case ID_VIEW_TRANSPARENTCOLOR: { static COLORREF customColors[16] = {0}; CHOOSECOLOR ccDlg = { 0 }; ccDlg.lStructSize = sizeof(ccDlg); ccDlg.hwndOwner = m_hwnd; ccDlg.rgbResult = transparentColor; ccDlg.lpCustColors = customColors; ccDlg.Flags = CC_RGBINIT | CC_FULLOPEN; if(ChooseColor(&ccDlg)) { transparentColor = ccDlg.rgbResult; picWindow1.SetTransparentColor(transparentColor); picWindow2.SetTransparentColor(transparentColor); picWindow3.SetTransparentColor(transparentColor); // The color picker takes the focus and we don't get it back. ::SetFocus(picWindow1); } } break; case ID_VIEW_FITIMAGEWIDTHS: { bFitWidths = !bFitWidths; picWindow1.FitWidths(bFitWidths); picWindow2.FitWidths(bFitWidths); picWindow3.FitWidths(bFitWidths); HMENU hMenu = GetMenu(*this); UINT uCheck = MF_BYCOMMAND; uCheck |= bFitWidths ? MF_CHECKED : MF_UNCHECKED; CheckMenuItem(hMenu, ID_VIEW_FITIMAGEWIDTHS, uCheck); // change the state of the toolbar button TBBUTTONINFO tbi; tbi.cbSize = sizeof(TBBUTTONINFO); tbi.dwMask = TBIF_STATE; tbi.fsState = bFitWidths ? TBSTATE_CHECKED | TBSTATE_ENABLED : TBSTATE_ENABLED; SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_FITIMAGEWIDTHS, (LPARAM)&tbi); } break; case ID_VIEW_FITIMAGEHEIGHTS: { bFitHeights = !bFitHeights; picWindow1.FitHeights(bFitHeights); picWindow2.FitHeights(bFitHeights); picWindow3.FitHeights(bFitHeights); HMENU hMenu = GetMenu(*this); UINT uCheck = MF_BYCOMMAND; uCheck |= bFitHeights ? MF_CHECKED : MF_UNCHECKED; CheckMenuItem(hMenu, ID_VIEW_FITIMAGEHEIGHTS, uCheck); // change the state of the toolbar button TBBUTTONINFO tbi; tbi.cbSize = sizeof(TBBUTTONINFO); tbi.dwMask = TBIF_STATE; tbi.fsState = bFitHeights ? TBSTATE_CHECKED | TBSTATE_ENABLED : TBSTATE_ENABLED; SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_FITIMAGEHEIGHTS, (LPARAM)&tbi); } break; case ID_VIEW_LINKIMAGESTOGETHER: { bLinkedPositions = !bLinkedPositions; picWindow1.LinkPositions(bLinkedPositions); picWindow2.LinkPositions(bLinkedPositions); picWindow3.LinkPositions(bLinkedPositions); HMENU hMenu = GetMenu(*this); UINT uCheck = MF_BYCOMMAND; uCheck |= bLinkedPositions ? MF_CHECKED : MF_UNCHECKED; CheckMenuItem(hMenu, ID_VIEW_LINKIMAGESTOGETHER, uCheck); // change the state of the toolbar button TBBUTTONINFO tbi; tbi.cbSize = sizeof(TBBUTTONINFO); tbi.dwMask = TBIF_STATE; tbi.fsState = bLinkedPositions ? TBSTATE_CHECKED | TBSTATE_ENABLED : TBSTATE_ENABLED; SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_LINKIMAGESTOGETHER, (LPARAM)&tbi); } break; case ID_VIEW_ALPHA0: picWindow1.SetBlendAlpha(m_BlendType, 0.0f); break; case ID_VIEW_ALPHA255: picWindow1.SetBlendAlpha(m_BlendType, 1.0f); break; case ID_VIEW_ALPHA127: picWindow1.SetBlendAlpha(m_BlendType, 0.5f); break; case ID_VIEW_ALPHATOGGLE: picWindow1.ToggleAlpha(); break; case ID_VIEW_FITIMAGESINWINDOW: { picWindow1.FitImageInWindow(); picWindow2.FitImageInWindow(); picWindow3.FitImageInWindow(); } break; case ID_VIEW_ORININALSIZE: { picWindow1.SetZoom(100, false); picWindow2.SetZoom(100, false); picWindow3.SetZoom(100, false); picWindow1.CenterImage(); picWindow2.CenterImage(); picWindow3.CenterImage(); } break; case ID_VIEW_ZOOMIN: { picWindow1.Zoom(true, false); if ((!(bFitWidths || bFitHeights))&&(!bOverlap)) { picWindow2.Zoom(true, false); picWindow3.Zoom(true, false); } } break; case ID_VIEW_ZOOMOUT: { picWindow1.Zoom(false, false); if ((!(bFitWidths || bFitHeights))&&(!bOverlap)) { picWindow2.Zoom(false, false); picWindow3.Zoom(false, false); } } break; case ID_VIEW_ARRANGEVERTICAL: { bVertical = !bVertical; RECT rect; GetClientRect(*this, &rect); if (bVertical) { RECT tbRect; GetWindowRect(hwndTB, &tbRect); LONG tbHeight = tbRect.bottom-tbRect.top-1; if (selectionPaths.size() != 3) { nSplitterPos = (rect.bottom-rect.top)/2+tbHeight; nSplitterPos2 = 0; } else { nSplitterPos = (rect.bottom-rect.top)/3+tbHeight; nSplitterPos2 = (rect.bottom-rect.top)*2/3+tbHeight; } } else { if (selectionPaths.size() != 3) { nSplitterPos = (rect.right-rect.left)/2; nSplitterPos2 = 0; } else { nSplitterPos = (rect.right-rect.left)/3; nSplitterPos2 = (rect.right-rect.left)*2/3; } } HMENU hMenu = GetMenu(*this); UINT uCheck = MF_BYCOMMAND; uCheck |= bVertical ? MF_CHECKED : MF_UNCHECKED; CheckMenuItem(hMenu, ID_VIEW_ARRANGEVERTICAL, uCheck); // change the state of the toolbar button TBBUTTONINFO tbi; tbi.cbSize = sizeof(TBBUTTONINFO); tbi.dwMask = TBIF_STATE; tbi.fsState = bVertical ? TBSTATE_CHECKED | TBSTATE_ENABLED : TBSTATE_ENABLED; SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_ARRANGEVERTICAL, (LPARAM)&tbi); PositionChildren(&rect); } break; case ID_ABOUT: { CAboutDlg dlg(*this); dlg.DoModal(hInst, IDD_ABOUT, *this); } break; case SELECTBUTTON_ID: { HWND hSource = (HWND)lParam; FileType resolveWith; if (picWindow1 == hSource) resolveWith = FileTypeMine; else if (picWindow2 == hSource) resolveWith = FileTypeBase; else if (picWindow3 == hSource) resolveWith = FileTypeTheirs; else break; if (selectionResult.empty()) { PostQuitMessage(resolveWith); break; } CopyFile(selectionPaths[resolveWith].c_str(), selectionResult.c_str(), FALSE); CAutoBuf projectRoot; if (git_repository_discover(projectRoot, CUnicodeUtils::GetUTF8(selectionResult.c_str()), FALSE, nullptr) < 0 && strstr(projectRoot->ptr, "/.git/")) { PostQuitMessage(resolveWith); break; } CAutoRepository repository(projectRoot->ptr); if (!repository) { PostQuitMessage(resolveWith); break; } CStringA subpath = CUnicodeUtils::GetUTF8(selectionResult.c_str()).Mid((int)strlen(git_repository_workdir(repository))); CAutoIndex index; if (git_repository_index(index.GetPointer(), repository) || (git_index_get_bypath(index, subpath, 1) == nullptr && git_index_get_bypath(index, subpath, 2) == nullptr)) { PostQuitMessage(resolveWith); break; } CString sTemp; sTemp.Format(ResString(hResource, IDS_MARKASRESOLVED), (LPCTSTR)CPathUtils::GetFileNameFromPath(selectionResult.c_str())); if (MessageBox(m_hwnd, sTemp, L"TortoiseGitMerge", MB_YESNO | MB_ICONQUESTION) != IDYES) break; CString cmd; cmd.Format(L"\"%sTortoiseGitProc.exe\" /command:resolve /path:\"%s\" /closeonend:1 /noquestion /skipcheck /silent", (LPCTSTR)CPathUtils::GetAppDirectory(), selectionResult.c_str()); if (resolveMsgWnd) cmd.AppendFormat(L" /resolvemsghwnd:%I64d /resolvemsgwparam:%I64d /resolvemsglparam:%I64d", (__int64)resolveMsgWnd, (__int64)resolveMsgWParam, (__int64)resolveMsgLParam); STARTUPINFO startup = { 0 }; PROCESS_INFORMATION process = { 0 }; startup.cb = sizeof(startup); if (!CreateProcess(nullptr, cmd.GetBuffer(), nullptr, nullptr, FALSE, CREATE_UNICODE_ENVIRONMENT, nullptr, nullptr, &startup, &process)) { cmd.ReleaseBuffer(); PostQuitMessage(resolveWith); break; } cmd.ReleaseBuffer(); AllowSetForegroundWindow(process.dwProcessId); CloseHandle(process.hThread); CloseHandle(process.hProcess); PostQuitMessage(resolveWith); } break; case IDM_EXIT: ::PostQuitMessage(0); return 0; break; default: break; }; return 1; }
int CRepositoryBrowser::ReadTree(CShadowFilesTree * treeroot, const CString& root) { CWaitCursor wait; CAutoRepository repository(g_Git.GetGitRepository()); if (!repository) { MessageBox(CGit::GetLibGit2LastErr(_T("Could not open repository.")), _T("TortoiseGit"), MB_ICONERROR); return -1; } if (m_sRevision == _T("HEAD")) { int ret = git_repository_head_unborn(repository); if (ret == 1) // is orphan return ret; else if (ret != 0) { MessageBox(g_Git.GetLibGit2LastErr(_T("Could not check HEAD.")), _T("TortoiseGit"), MB_ICONERROR); return ret; } } CGitHash hash; if (CGit::GetHash(repository, hash, m_sRevision)) { MessageBox(CGit::GetLibGit2LastErr(_T("Could not get hash of ") + m_sRevision + _T(".")), _T("TortoiseGit"), MB_ICONERROR); return -1; } CAutoCommit commit; if (git_commit_lookup(commit.GetPointer(), repository, (git_oid *)hash.m_hash)) { MessageBox(CGit::GetLibGit2LastErr(_T("Could not lookup commit.")), _T("TortoiseGit"), MB_ICONERROR); return -1; } CAutoTree tree; if (git_commit_tree(tree.GetPointer(), commit)) { MessageBox(CGit::GetLibGit2LastErr(_T("Could not get tree of commit.")), _T("TortoiseGit"), MB_ICONERROR); return -1; } if (!root.IsEmpty()) { CAutoTreeEntry treeEntry; if (git_tree_entry_bypath(treeEntry.GetPointer(), tree, CUnicodeUtils::GetUTF8(root))) { MessageBox(CGit::GetLibGit2LastErr(_T("Could not lookup path.")), _T("TortoiseGit"), MB_ICONERROR); return -1; } if (git_tree_entry_type(treeEntry) != GIT_OBJ_TREE) { MessageBox(CGit::GetLibGit2LastErr(_T("Could not lookup path.")), _T("TortoiseGit"), MB_ICONERROR); return -1; } CAutoObject object; if (git_tree_entry_to_object(object.GetPointer(), repository, treeEntry)) { MessageBox(CGit::GetLibGit2LastErr(_T("Could not lookup path.")), _T("TortoiseGit"), MB_ICONERROR); return -1; } tree = (git_tree*)object.Detach(); } treeroot->m_hash = CGitHash((char *)git_tree_id(tree)->id); ReadTreeRecursive(*repository, tree, treeroot); // try to resolve hash to a branch name if (m_sRevision == hash.ToString()) { MAP_HASH_NAME map; if (CGit::GetMapHashToFriendName(repository, map)) MessageBox(g_Git.GetLibGit2LastErr(_T("Could not get all refs.")), _T("TortoiseGit"), MB_ICONERROR); if (!map[hash].empty()) m_sRevision = map[hash].at(0); } this->GetDlgItem(IDC_BUTTON_REVISION)->SetWindowText(m_sRevision); return 0; }
/** \brief Add a package by package name, and option version */ void package_list::add_package( const std::string& package, const std::string& version, const bool force_reinstall ) { const wpkg_filename::uri_filename pck(package); list_t::const_iterator item(find_package_item(pck)); if(item != f_packages.end()) { // the user is trying to install the same package twice // (ignore if that's exactly the same one) if(item->get_type() != package_item_t::package_type_explicit) { wpkg_output::log("package %1 defined twice on your command line using two different paths.") .quoted_arg(package) .level(wpkg_output::level_error) .module(wpkg_output::module_validate_installation) .package(package) .action("install-validation"); } } else { if( pck.extension() == "deb") { // this is an explicit package package_item_t package_item( f_manager, pck ); f_packages.push_back(package_item); } else { wpkgar_repository repository( f_manager ); typedef std::map<std::string,wpkgar_repository::package_item_t> version_package_map_t; version_package_map_t version_map; for( const auto& entry : repository.upgrade_list() ) { if( entry.get_name() == package ) { version_map[entry.get_version()] = entry; } } if( version_map.empty() ) { std::stringstream ss; ss << "Cannot install package '" << package << "' because it doesn't exist in the repository!"; throw std::runtime_error(ss.str()); } if( version.empty() ) { auto greatest_version( version_map.rbegin()->first ); if( version_map.size() > 1 ) { wpkg_output::log("package '%1' has multiple versions available in the selected repositories. Selected the greatest version '%2'.") .quoted_arg(package) .quoted_arg(greatest_version) .level(wpkg_output::level_warning) .module(wpkg_output::module_validate_installation) .package(package) .action("install-validation"); } // Select the greatest version // add_package( version_map.rbegin()->second, force_reinstall ); } else { add_package( version_map[version], force_reinstall ); } } } }
void CGitPropertyPage::InitWorkfileView() { if (filenames.empty()) return; CTGitPath path(filenames.front().c_str()); CString ProjectTopDir; if(!path.HasAdminDir(&ProjectTopDir)) return; CAutoRepository repository(CUnicodeUtils::GetUTF8(ProjectTopDir)); if (!repository) return; CString username; CString useremail; CString autocrlf; CString safecrlf; CAutoConfig config(repository); if (config) { config.GetString(L"user.name", username); config.GetString(L"user.email", useremail); config.GetString(L"core.autocrlf", autocrlf); config.GetString(L"core.safecrlf", safecrlf); } CString branch; CString remotebranch; if (!git_repository_head_detached(repository)) { CAutoReference head; if (git_repository_head_unborn(repository)) { git_reference_lookup(head.GetPointer(), repository, "HEAD"); branch = CUnicodeUtils::GetUnicode(git_reference_symbolic_target(head)); if (branch.Find(_T("refs/heads/")) == 0) branch = branch.Mid(11); // 11 = len("refs/heads/") } else if (!git_repository_head(head.GetPointer(), repository)) { const char * branchChar = git_reference_shorthand(head); branch = CUnicodeUtils::GetUnicode(branchChar); const char * branchFullChar = git_reference_name(head); CAutoBuf upstreambranchname; if (!git_branch_upstream_name(upstreambranchname, repository, branchFullChar)) { remotebranch = CUnicodeUtils::GetUnicode(CStringA(upstreambranchname->ptr, (int)upstreambranchname->size)); remotebranch = remotebranch.Mid(13); // 13=len("refs/remotes/") } } } else branch = _T("detached HEAD"); if (autocrlf.Trim().IsEmpty()) autocrlf = _T("false"); if (safecrlf.Trim().IsEmpty()) safecrlf = _T("false"); SetDlgItemText(m_hwnd,IDC_CONFIG_USERNAME,username.Trim()); SetDlgItemText(m_hwnd,IDC_CONFIG_USEREMAIL,useremail.Trim()); SetDlgItemText(m_hwnd,IDC_CONFIG_AUTOCRLF,autocrlf.Trim()); SetDlgItemText(m_hwnd,IDC_CONFIG_SAFECRLF,safecrlf.Trim()); SetDlgItemText(m_hwnd,IDC_SHELL_CURRENT_BRANCH,branch.Trim()); SetDlgItemText(m_hwnd,IDC_SHELL_REMOTE_BRANCH, remotebranch); git_oid oid; CAutoCommit HEADcommit; if (!git_reference_name_to_id(&oid, repository, "HEAD") && !git_commit_lookup(HEADcommit.GetPointer(), repository, &oid) && HEADcommit) DisplayCommit(HEADcommit, IDC_HEAD_HASH, IDC_HEAD_SUBJECT, IDC_HEAD_AUTHOR, IDC_HEAD_DATE); { int stripLength = ProjectTopDir.GetLength(); if (ProjectTopDir[stripLength - 1] != _T('\\')) ++stripLength; bool allAreFiles = true; for (auto it = filenames.cbegin(); it < filenames.cend(); ++it) { if (PathIsDirectory(it->c_str())) { allAreFiles = false; break; } } if (allAreFiles) { size_t assumevalid = 0; size_t skipworktree = 0; size_t executable = 0; size_t symlink = 0; do { CAutoIndex index; if (git_repository_index(index.GetPointer(), repository)) break; for (auto it = filenames.cbegin(); it < filenames.cend(); ++it) { CTGitPath file; file.SetFromWin(CString(it->c_str()).Mid(stripLength)); CStringA pathA = CUnicodeUtils::GetMulti(file.GetGitPathString(), CP_UTF8); size_t idx; if (!git_index_find(&idx, index, pathA)) { const git_index_entry *e = git_index_get_byindex(index, idx); if (e->flags & GIT_IDXENTRY_VALID) ++assumevalid; if (e->flags_extended & GIT_IDXENTRY_SKIP_WORKTREE) ++skipworktree; if (e->mode & 0111) ++executable; if ((e->mode & GIT_FILEMODE_LINK) == GIT_FILEMODE_LINK) ++symlink; } else { // do not show checkboxes for unversioned files ShowWindow(GetDlgItem(m_hwnd, IDC_ASSUMEVALID), SW_HIDE); ShowWindow(GetDlgItem(m_hwnd, IDC_SKIPWORKTREE), SW_HIDE); ShowWindow(GetDlgItem(m_hwnd, IDC_EXECUTABLE), SW_HIDE); ShowWindow(GetDlgItem(m_hwnd, IDC_SYMLINK), SW_HIDE); break; } } } while (0); if (assumevalid != 0 && assumevalid != filenames.size()) { SendMessage(GetDlgItem(m_hwnd, IDC_ASSUMEVALID), BM_SETSTYLE, (DWORD)GetWindowLong(GetDlgItem(m_hwnd, IDC_ASSUMEVALID), GWL_STYLE) & ~BS_AUTOCHECKBOX | BS_AUTO3STATE, 0); SendMessage(GetDlgItem(m_hwnd, IDC_ASSUMEVALID), BM_SETCHECK, BST_INDETERMINATE, 0); } else SendMessage(GetDlgItem(m_hwnd, IDC_ASSUMEVALID), BM_SETCHECK, (assumevalid == 0) ? BST_UNCHECKED : BST_CHECKED, 0); if (skipworktree != 0 && skipworktree != filenames.size()) { SendMessage(GetDlgItem(m_hwnd, IDC_SKIPWORKTREE), BM_SETSTYLE, (DWORD)GetWindowLong(GetDlgItem(m_hwnd, IDC_SKIPWORKTREE), GWL_STYLE) & ~BS_AUTOCHECKBOX | BS_AUTO3STATE, 0); SendMessage(GetDlgItem(m_hwnd, IDC_SKIPWORKTREE), BM_SETCHECK, BST_INDETERMINATE, 0); } else SendMessage(GetDlgItem(m_hwnd, IDC_SKIPWORKTREE), BM_SETCHECK, (skipworktree == 0) ? BST_UNCHECKED : BST_CHECKED, 0); if (executable != 0 && executable != filenames.size()) { SendMessage(GetDlgItem(m_hwnd, IDC_EXECUTABLE), BM_SETSTYLE, (DWORD)GetWindowLong(GetDlgItem(m_hwnd, IDC_EXECUTABLE), GWL_STYLE) & ~BS_AUTOCHECKBOX | BS_AUTO3STATE, 0); SendMessage(GetDlgItem(m_hwnd, IDC_EXECUTABLE), BM_SETCHECK, BST_INDETERMINATE, 0); EnableWindow(GetDlgItem(m_hwnd, IDC_SYMLINK), TRUE); } else { SendMessage(GetDlgItem(m_hwnd, IDC_EXECUTABLE), BM_SETCHECK, (executable == 0) ? BST_UNCHECKED : BST_CHECKED, 0); EnableWindow(GetDlgItem(m_hwnd, IDC_SYMLINK), (executable == 0) ? TRUE : FALSE); } if (symlink != 0 && symlink != filenames.size()) { SendMessage(GetDlgItem(m_hwnd, IDC_SYMLINK), BM_SETSTYLE, (DWORD)GetWindowLong(GetDlgItem(m_hwnd, IDC_SYMLINK), GWL_STYLE) & ~BS_AUTOCHECKBOX | BS_AUTO3STATE, 0); SendMessage(GetDlgItem(m_hwnd, IDC_SYMLINK), BM_SETCHECK, BST_INDETERMINATE, 0); EnableWindow(GetDlgItem(m_hwnd, IDC_EXECUTABLE), TRUE); } else { SendMessage(GetDlgItem(m_hwnd, IDC_SYMLINK), BM_SETCHECK, (symlink == 0) ? BST_UNCHECKED : BST_CHECKED, 0); EnableWindow(GetDlgItem(m_hwnd, IDC_EXECUTABLE), (symlink == 0) ? TRUE : FALSE); } } else { ShowWindow(GetDlgItem(m_hwnd, IDC_ASSUMEVALID), SW_HIDE); ShowWindow(GetDlgItem(m_hwnd, IDC_SKIPWORKTREE), SW_HIDE); ShowWindow(GetDlgItem(m_hwnd, IDC_EXECUTABLE), SW_HIDE); ShowWindow(GetDlgItem(m_hwnd, IDC_SYMLINK), SW_HIDE); } } if (filenames.size() == 1 && !PathIsDirectory(filenames[0].c_str())) { SetDlgItemText(m_hwnd, IDC_LAST_SUBJECT, CString(MAKEINTRESOURCE(IDS_LOADING))); _beginthread(LogThreadEntry, 0, this); } else ShowWindow(GetDlgItem(m_hwnd, IDC_STATIC_LASTMODIFIED), SW_HIDE); }
BOOL CGitPropertyPage::PageProc (HWND /*hwnd*/, UINT uMessage, WPARAM wParam, LPARAM lParam) { switch (uMessage) { case WM_INITDIALOG: { InitWorkfileView(); return TRUE; } case WM_NOTIFY: { LPNMHDR point = (LPNMHDR)lParam; int code = point->code; // // Respond to notifications. // if (code == PSN_APPLY && m_bChanged) { do { CTGitPath path(filenames.front().c_str()); CString projectTopDir; if(!path.HasAdminDir(&projectTopDir) || path.IsDirectory()) break; int stripLength = projectTopDir.GetLength(); if (projectTopDir[stripLength - 1] != _T('\\')) ++stripLength; CAutoRepository repository(CUnicodeUtils::GetUTF8(projectTopDir)); if (!repository) break; CAutoIndex index; if (git_repository_index(index.GetPointer(), repository)) break; BOOL assumeValid = (BOOL)SendMessage(GetDlgItem(m_hwnd, IDC_ASSUMEVALID), BM_GETCHECK, 0, 0); BOOL skipWorktree = (BOOL)SendMessage(GetDlgItem(m_hwnd, IDC_SKIPWORKTREE), BM_GETCHECK, 0, 0); BOOL executable = (BOOL)SendMessage(GetDlgItem(m_hwnd, IDC_EXECUTABLE), BM_GETCHECK, 0, 0); BOOL symlink = (BOOL)SendMessage(GetDlgItem(m_hwnd, IDC_SYMLINK), BM_GETCHECK, 0, 0); bool changed = false; for (auto it = filenames.cbegin(); it < filenames.cend(); ++it) { CTGitPath file; file.SetFromWin(CString(it->c_str()).Mid(stripLength)); CStringA pathA = CUnicodeUtils::GetMulti(file.GetGitPathString(), CP_UTF8); size_t idx; if (!git_index_find(&idx, index, pathA)) { git_index_entry *e = const_cast<git_index_entry *>(git_index_get_byindex(index, idx)); // HACK if (assumeValid == BST_CHECKED) { if (!(e->flags & GIT_IDXENTRY_VALID)) { e->flags |= GIT_IDXENTRY_VALID; changed = true; } } else if (assumeValid != BST_INDETERMINATE) { if (e->flags & GIT_IDXENTRY_VALID) { e->flags &= ~GIT_IDXENTRY_VALID; changed = true; } } if (skipWorktree == BST_CHECKED) { if (!(e->flags_extended & GIT_IDXENTRY_SKIP_WORKTREE)) { e->flags_extended |= GIT_IDXENTRY_SKIP_WORKTREE; changed = true; } } else if (skipWorktree != BST_INDETERMINATE) { if (e->flags_extended & GIT_IDXENTRY_SKIP_WORKTREE) { e->flags_extended &= ~GIT_IDXENTRY_SKIP_WORKTREE; changed = true; } } if (executable == BST_CHECKED) { if (!(e->mode & 0111)) { e->mode |= 0111; changed = true; } } else if (executable != BST_INDETERMINATE) { if (e->mode & 0111) { e->mode &= ~0111; changed = true; } } if (symlink == BST_CHECKED) { if ((e->mode & GIT_FILEMODE_LINK) != GIT_FILEMODE_LINK) { e->mode |= GIT_FILEMODE_LINK; changed = true; } } else if (symlink != BST_INDETERMINATE) { if ((e->mode & GIT_FILEMODE_LINK) == GIT_FILEMODE_LINK) { e->mode &= ~GIT_FILEMODE_LINK; changed = true; } } if (changed) git_index_add(index, e); } } if (changed) { if (!git_index_write(index)) m_bChanged = false; } } while (0); } SetWindowLongPtr (m_hwnd, DWLP_MSGRESULT, FALSE); return TRUE; } case WM_DESTROY: return TRUE; case WM_COMMAND: PageProcOnCommand(wParam); break; } // switch (uMessage) if (uMessage == m_UpdateLastCommit) { DisplayCommit((git_commit *)lParam, IDC_LAST_HASH, IDC_LAST_SUBJECT, IDC_LAST_AUTHOR, IDC_LAST_DATE); return TRUE; } return FALSE; }
void CWmDrmDataStore::PrepareInfoFilesL( TBool aConfiguredDrive, TChar aDriveLetter, RFile& aDummyDb ) { LOGFN( "CWmDrmDataStore::PrepareInfoFilesL" ); CRepository* repository( NULL ); TInt r( KErrNone ); TFileName dummyDbFile; TFileName initialFreeSpaceFile; initialFreeSpaceFile.Format( KPrivateDir, (TUint)aDriveLetter ); iServer->Fs().MkDirAll( initialFreeSpaceFile ); initialFreeSpaceFile.Format( KInitialFreeSpaceFile, (TUint)aDriveLetter ); dummyDbFile.Format( KDummyDbFile, (TUint)aDriveLetter ); TRAP( r, WriteInitialFreeSpaceL( initialFreeSpaceFile, aConfiguredDrive ) ); if ( r ) { r = KErrNone; // catch the read error TRAP( r, ReadInitialFreeSpaceL( initialFreeSpaceFile, aConfiguredDrive ) ); // if an error occurs, this means that we are unable to read the info, // thus we need to delete the file and run write again. // hopefully this being a temporary error, but if we fail again we fail // until next ConstructL if( r != KErrNone ) { // delete the file: iServer->Fs().Delete( initialFreeSpaceFile ); // Calc & Write the new info WriteInitialFreeSpaceL( initialFreeSpaceFile, aConfiguredDrive ); } } if ( aConfiguredDrive ) { #ifdef _LOGGING TBuf<KMaxTInt64BufLength> freeSpace2; LOG1( "CWmDrmDataStore::DataStoreStateL: Initial free space (2): "); freeSpace2.AppendNumUC( iInitialFreeSpace2, EDecimal ); LOG( freeSpace2 ); #endif if ( iInitialFreeSpace2 <= 0 ) { User::Leave( KErrNotReady ); } } else { #ifdef _LOGGING TBuf<KMaxTInt64BufLength> freeSpace; LOG1( "CWmDrmDataStore::DataStoreStateL: Initial free space: "); freeSpace.AppendNumUC( iInitialFreeSpace, EDecimal ); LOG( freeSpace ); #endif if ( iInitialFreeSpace <= 0 ) { User::Leave( KErrNotReady ); } } //LOG1( "CWmDrmDataStore::PrepareInfoFilesL Check Cenrep" ); TRAP( r, repository = CRepository::NewL( KCRUidWMDRM ) ); if ( repository ) { TInt rate( 0 ); // Check the cenrep key parameters either for the default system drive // or for the internal mass drive depending whether the WMDRM rights // are configured to be partially stored to the internal mass drive or // not. if ( !aConfiguredDrive ) { r = repository->Get( KWMDRMLicStoreLowMem, rate ); if ( r ) { iMinFreeSpace = KMegaByte; } else { iMinFreeSpace = rate * KMegaByte; } r = repository->Get( KWMDRMLicStoreSizeRatio, iMaxSpaceRatio ); if ( r ) { iMaxSpaceRatio = KMaxSpaceRatio; } r = repository->Get( KWMDRMLicStoreReservedSpace, rate ); if ( r ) { iDummyDbInitialSize = KDummyDbInitialSize; } else { iDummyDbInitialSize = rate * KMegaByte; } } else { r = repository->Get( KWMDRM2LicStoreLowMem, rate ); if ( r ) { iMinFreeSpace2 = KTwoHundredMegaBytes; } else { iMinFreeSpace2 = rate * KMegaByte; } r = repository->Get( KWMDRM2LicStoreSizeRatio, iMaxSpaceRatio2 ); if ( r ) { iMaxSpaceRatio2 = KMaxSpaceRatio2; } r = repository->Get( KWMDRM2LicStoreReservedSpace, rate ); if ( r ) { iDummyDbInitialSize2 = KDummyDbInitialSize; } else { iDummyDbInitialSize2 = rate * KMegaByte; } } delete repository; } else { if ( !aConfiguredDrive ) { iMinFreeSpace = KMegaByte; iMaxSpaceRatio = KMaxSpaceRatio; iDummyDbInitialSize = KDummyDbInitialSize; } else { iMinFreeSpace2 = KTwoHundredMegaBytes; iMaxSpaceRatio2 = KMaxSpaceRatio2; iDummyDbInitialSize2 = KDummyDbInitialSize; } } InitializeDummyDbFileL( dummyDbFile, aDummyDb, aConfiguredDrive ); }
int main(int argc, char* argv[]) { try { OptionManager om; try { getOptions(om, argc, argv); } catch(Exception &e) { cerr << argv[0] << ":" << e.getMessage() << endl; String header = "Usage "; String trailer =""; om.printOptionsHelpTxt(header, trailer); exit(1); } String parent; String repositoryPath; String namespaceName; String location; String shareable; String updatesAllowed; om.lookupValue("parent", parent); om.lookupValue("repositoryPath", repositoryPath); om.lookupValue("namespaceName", namespaceName); om.lookupValue("location", location); om.lookupValue("shareable", shareable); om.lookupValue("updatesAllowed", updatesAllowed); CIMRepository repository(repositoryPath); CIMRepository::NameSpaceAttributes attributes; if (parent.size()) { // Check if parent namespace is shareable else modify to be // shareable. repository.getNameSpaceAttributes(parent, attributes); for (CIMRepository::NameSpaceAttributes::Iterator i = attributes.start(); i; i++) { String key = i.key(); String value = i.value(); if (String::equalNoCase(key, "shareable")) { if (String::equalNoCase(value, "false")) { CIMRepository::NameSpaceAttributes attr; attr.insert("shareable", "true"); repository.modifyNameSpace( parent, attr); break; } } } attributes.clear(); attributes.insert("parent", parent); } attributes.insert("remoteInfo", location); attributes.insert("shareable", shareable); attributes.insert("updatesAllowed", updatesAllowed); repository.createNameSpace(namespaceName, attributes); } catch(Exception &e) { cerr << argv[0] << ":" << e.getMessage() << endl; exit(1); } catch(...) { cerr << argv[0] << ":" << "Unknown error" << endl; exit(1); } cout << "Namespace created successfully." << endl; return 0; }
Document::List SQLiteDocumentDAO::findAll() const { return repository()->publications()->findAll(); }
// ----------------------------------------------------------------------------- // CSconVersionInfo::FetchInfoL() // fetch device info // ----------------------------------------------------------------------------- // void CSconVersionInfo::FetchInfoL( RFs& aFs ) { TRACE_FUNC_ENTRY; iSymbianVersionError = SysVersionInfo::GetVersionInfo( iSymbianVersion, aFs ); iS60VersionError = VersionInfo::GetVersion( iS60Version, aFs ); TBuf<KSysVersionInfoTextLength> info; TBuf<KSysVersionInfoTextLength> productBuf; TInt err(KErrNone); delete iSWVersion; iSWVersion = NULL; delete iProduct; iProduct = NULL; // get SW version, SW version date and model TRAP( err, CapUtil::GetSWVersionL( info, iDate, productBuf ) ); iSWVersion = info.AllocL(); iProduct = productBuf.AllocL(); LOGGER_WRITE_1("CapUtil::GetSWVersionL err: %d", err); SysVersionInfo::TProductVersion productVersion; TInt sysVersionError = SysVersionInfo::GetVersionInfo( productVersion, aFs ); LOGGER_WRITE_1( "SysVersionInfo::GetVersionInfo returned : %d", sysVersionError ); // Use TelServer to get IMEI and also other info if SysVersionInfo is not supported RTelServer telServer; User::LeaveIfError( telServer.Connect() ); CleanupClosePushL( telServer ); RTelServer::TPhoneInfo teleinfo; User::LeaveIfError( telServer.GetPhoneInfo( 0, teleinfo ) ); RMobilePhone phone; User::LeaveIfError( phone.Open( telServer, teleinfo.iName ) ); CleanupClosePushL( phone ); User::LeaveIfError(phone.Initialise()); TUint32 teleidentityCaps; phone.GetIdentityCaps( teleidentityCaps ); RMobilePhone::TMobilePhoneIdentityV1 telid; TRequestStatus status; phone.GetPhoneId( status, telid ); User::WaitForRequest( status ); if ( status == KErrNone ) { if ( sysVersionError ) { LOGGER_WRITE("Use info from TMobilePhoneIdentityV1"); delete iModel; iModel = NULL; delete iRevision; iRevision = NULL; // phone model sales name. For example "N01". iModel = telid.iModel.AllocL(); // product revision. For example "01" iRevision = telid.iRevision.AllocL(); } delete iSerialNumber; iSerialNumber = NULL; // Phone serial number (IMEI or ESN), in character string format. iSerialNumber = telid.iSerialNumber.AllocL(); } CleanupStack::PopAndDestroy( &phone ); CleanupStack::PopAndDestroy( &telServer ); if ( sysVersionError == KErrNone ) { // use information from SysVersionInfo instead of previous APIs. LOGGER_WRITE("Using SysVersionInfo"); // phone model sales name. For example "N01". delete iModel; iModel = NULL; iModel = productVersion.iModel.AllocL(); // product revision. For example "01" delete iRevision; iRevision = NULL; iRevision = productVersion.iRevision.AllocL(); // manufacturer name. For example "Nokia" delete iManufacturer; iManufacturer = NULL; iManufacturer = productVersion.iManufacturer.AllocL(); // product code name. For example "RM-1" delete iProduct; iProduct = NULL; iProduct = productVersion.iProduct.AllocL(); } else { CapUtil::GetManufacturer( info ); delete iManufacturer; iManufacturer = NULL; iManufacturer = info.AllocL(); } CapUtil::GetLanguage( iLanguage ); err = SysVersionInfo::GetVersionInfo( SysVersionInfo::EFWVersion, info, aFs ); delete iSysVersionInfo; iSysVersionInfo = NULL; if ( !err ) { iSysVersionInfo = info.AllocL(); } err = SysUtil::GetLangVersion( info ); delete iLangVersion; iLangVersion = NULL; if ( !err ) { iLangVersion = info.AllocL(); } sysVersionError = SysUtil::GetLangSWVersion( info ); delete iLangSWVersion; iLangSWVersion = NULL; if ( !sysVersionError ) { iLangSWVersion = info.AllocL(); } sysVersionError = SysVersionInfo::GetVersionInfo( SysVersionInfo::EOPVersion, info, aFs ); delete iOPVersion; iOPVersion = NULL; if ( !sysVersionError ) { iOPVersion = info.AllocL(); } sysVersionError = SysVersionInfo::GetVersionInfo( SysVersionInfo::EProductCode, info, aFs ); delete iProductCode; iProductCode = NULL; if ( !sysVersionError ) { iProductCode = info.AllocL(); } // read DesktopSync key value CRepository* repository(NULL); TRAP( iDesktopSyncError, repository = CRepository::NewL( KCRUidDSDCMOConfig )); if ( !iDesktopSyncError ) { iDesktopSyncError = repository->Get( KNsmlDesktopSync, iDesktopSync ); LOGGER_WRITE_1("iDesktopSyncError: %d", iDesktopSyncError ); LOGGER_WRITE_1("iDesktopSync: %d", iDesktopSync ); delete repository; } else { LOGGER_WRITE_1("Could not create CRepository, err: %d", iDesktopSyncError ); } // screen size HAL::Get(HAL::EDisplayXPixels, iScreenSize.iWidth); HAL::Get(HAL::EDisplayYPixels, iScreenSize.iHeight); iInfoFetched = ETrue; TRACE_FUNC_EXIT; }