void COwnedLostItem::SetHandledViaNetscape() { m_nHandleMethod = OL_OTHER_APP; // Get the app's name. CString netscapeName; char buffer[_MAX_PATH+1]; ::GetModuleFileName(theApp.m_hInstance, buffer, _MAX_PATH); char *pSlash = ::strrchr(buffer, '\\'); netscapeName = (char*)(pSlash+1); netscapeName.MakeUpper(); // Get the app's directory. Adequate heuristic for version-checking Netscape CString directoryName(buffer); directoryName.MakeUpper(); // Special Internet Shortcut check if (IsInternetShortcut()) { CInternetShortcut internetShortcut; if (!internetShortcut.ShellSupport()) { m_nHandleMethod = OL_CURRENT_NETSCAPE; return; } CString fileClass = GetInternetShortcutFileClass(); SetHandleMethodViaFileClass(fileClass, netscapeName, directoryName); return; } CPtrList* allHelpers = &(CHelperApp::m_cplHelpers); for (POSITION pos = allHelpers->GetHeadPosition(); pos != NULL;) { CHelperApp* app = (CHelperApp*)allHelpers->GetNext(pos); CString helperMime(app->cd_item->ci.type); if (helperMime == m_csMimeType) { // Found the helper app. See if Netscape is truly handling this mime type. CString fileClass(app->strFileClass); if (fileClass != "") { SetHandleMethodViaFileClass(fileClass, netscapeName, directoryName); return; } else m_bBroken = TRUE; // Treat as if ignored. Don't want to pop up a dialog over this. if (app->how_handle == HANDLE_VIA_NETSCAPE) m_nHandleMethod = OL_CURRENT_NETSCAPE; else m_nHandleMethod = OL_OTHER_APP; return; } } m_bBroken = TRUE; // Didn't even find this mime type. Don't want to fool with it. }
void COwnedLostItem::GiveControlToNetscape() { char buffer[_MAX_PATH]; ::GetModuleFileName(theApp.m_hInstance, buffer, _MAX_PATH); // Get the app's directory into a short file name char shortBuffer[_MAX_PATH]; GetShortPathName(buffer, shortBuffer, _MAX_PATH); CString directoryName(shortBuffer); directoryName.MakeUpper(); // This is what we'll write to the registry CString strValueName, strCmdPath; // Special Internet Shortcut check if (IsInternetShortcut()) { CInternetShortcut internetShortcut; if (internetShortcut.ShellSupport()) { // Need to take over lots of stuff CString strType = GetInternetShortcutFileClass(); // Set the open command path strValueName.Format(strOPEN_CMD_FMT, (const char *)strType); strCmdPath = directoryName + " -h \"%1\""; FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strCmdPath); // Set the DDE exec value strValueName.Format(strDDE_EXEC_FMT, (const char *)strType); FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDE_EXEC_VALUE); // Set the DDE app name strValueName.Format(strDDE_APP_FMT, (const char *)strType); FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDE_APP_NAME); // Set the DDE topic strValueName.Format(strDDE_TOPIC_FMT, (const char *)strType); CString strDDETopic; strDDETopic.LoadString(IDS_DDE_OPENURL); FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDETopic); // Set the Default Icon CString strIconPath; if ((strType == "news") || (strType == "snews")) { // Use the news icon from URL.DLL ::GetSystemDirectory(buffer, _MAX_PATH); strIconPath = CString(buffer) + "\\URL.DLL,1"; } else { // Use the document icon strIconPath = CString(buffer) + ",1"; } strValueName.Format(strDEF_ICON_FMT, (const char *)strType); FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strIconPath); // Take over printing (applies to ALL Internet Shortcuts. If we own one, we'll take // over printing for ALL of them). CString csMunge = directoryName + " /print(\"%1\")"; FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\print\\command", csMunge); FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\print\\ddeexec", "[print(\"%1\")]"); FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\print\\ddeexec\\Application", strDDE_APP_NAME); // The PrintTo Command. csMunge = directoryName + " /printto(\"%1\",\"%2\",\"%3\",\"%4\")"; FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\PrintTo\\command", csMunge); FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\PrintTo\\ddeexec", "[printto(\"%1\",\"%2\",\"%3\",\"%4\")]"); FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\PrintTo\\ddeexec\\Application", strDDE_APP_NAME); } return; } CPtrList* allHelpers = &(CHelperApp::m_cplHelpers); for (POSITION pos = allHelpers->GetHeadPosition(); pos != NULL;) { CHelperApp* app = (CHelperApp*)allHelpers->GetNext(pos); CString helperMime(app->cd_item->ci.type); if (helperMime == m_csMimeType) { // Found the helper app. Get the file class. CString fileClass(app->strFileClass); if (fileClass != "") { // We have some registry work to do. // In the case where this is text/html, we point .htm and .html to // NetscapeMarkup. HKEY hKey; DWORD dwDisp; if (m_csMimeType == "text/html") { ::RegCreateKeyEx(HKEY_CLASSES_ROOT, ".htm", 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp); ::RegSetValueEx(hKey, NULL, 0L, REG_SZ, (const BYTE *)((const char *)strMARKUP_KEY), strMARKUP_KEY.GetLength() + 1); ::RegCloseKey(hKey); ::RegCreateKeyEx(HKEY_CLASSES_ROOT, ".html", 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp); ::RegSetValueEx(hKey, NULL, 0L, REG_SZ, (const BYTE *)((const char *)strMARKUP_KEY), strMARKUP_KEY.GetLength() + 1); ::RegCloseKey(hKey); } // In the case where this is application/x-unknown-content-type-NetscapeMarkup, // we point .shtml to NetscapeMarkup. else if (m_csMimeType == "application/x-unknown-content-type-NetscapeMarkup") { ::RegCreateKeyEx(HKEY_CLASSES_ROOT, ".shtml", 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp); ::RegSetValueEx(hKey, NULL, 0L, REG_SZ, (const BYTE *)((const char *)strMARKUP_KEY), strMARKUP_KEY.GetLength() + 1); ::RegCloseKey(hKey); } // In all other cases, we should use the existing file class else { // Need to take over lots of stuff CString strType = fileClass; if (strType == "NetscapeMarkup") return; // Don't let ANYTHING mess with NetscapeMarkup. // Someone might point something to it later, and // we don't want this code changing the stuff that's already there. // Set the open command path strValueName.Format(strOPEN_CMD_FMT, (const char *)strType); strCmdPath = directoryName + " \"%1\""; FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strCmdPath); // Set the DDE exec value strValueName.Format(strDDE_EXEC_FMT, (const char *)strType); FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDE_EXEC_VALUE); // Set the DDE app name strValueName.Format(strDDE_APP_FMT, (const char *)strType); FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDE_APP_NAME); // Set the DDE topic strValueName.Format(strDDE_TOPIC_FMT, (const char *)strType); CString strDDETopic; strDDETopic.LoadString(IDS_DDE_OPENURL); FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDETopic); // Set the Default Icon CString strIconPath; CString iconString = ",1"; if (m_csMimeType == "text/x-javascript" || m_csMimeType == "application/x-javascript") iconString = ",7"; else if (m_csMimeType.Left(5) == "image") iconString = ",6"; strIconPath = CString(buffer) + iconString; strValueName.Format(strDEF_ICON_FMT, (const char *)strType); FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strIconPath); } } return; } } }
bool PathManager::ReplaceAppPakNameInManifest(QString &path, QString &oldName, QString &newName) { QString manifest = path + "/" + "AndroidManifest.xml"; QFile file(manifest); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){ return false; } QDomDocument doc; if (!doc.setContent(&file)){ file.close(); return false; } file.close(); QDomElement root = doc.documentElement(); if (root.tagName() != "manifest"){ return false; } QString pack = root.attribute("package"); if (pack.isEmpty()){ return false; } root.setAttribute("package", newName); QList<QDomElement> allNode; if (!root.firstChildElement().isNull()){ QList<QDomElement> traversal; traversal.push_back(root.firstChildElement()); for (int i = 0; i < traversal.size(); i++) { QDomElement indexNode = traversal.at(i); while (!indexNode.isNull()) { if (indexNode.hasChildNodes()){ traversal.push_back(indexNode.firstChildElement()); } allNode.push_back(indexNode); indexNode = indexNode.nextSiblingElement(); } } } for (QList<QDomElement>::Iterator ite = allNode.begin(); ite != allNode.end(); ite++) { QDomElement element = *ite; if (!element.isNull()){ QString androidNm = element.attribute("android:name", ""); androidNm = androidNm.toLower(); QString fileStr = androidNm; fileStr.replace(".", "/"); fileStr = path + "/src/" + fileStr + ".java"; QFile fileClass(fileStr); if (androidNm.contains(oldName) && !fileClass.exists()){ androidNm.replace(oldName, newName); element.setAttribute("android:name", androidNm); } } } QFile filexml(manifest); if (!filexml.open(QFile::WriteOnly | QFile::Truncate)){ qWarning("error::ParserXML->writeOperateXml->file.open\n"); return false; } QTextStream ts(&filexml); ts.reset(); ts.setCodec("utf-8"); doc.save(ts, 4, QDomNode::EncodingFromTextStream); filexml.close(); return true; }