⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 browser_config.cpp

📁 ncbi源码
💻 CPP
字号:
/* * =========================================================================== * PRODUCTION $Log: browser_config.cpp,v $ * PRODUCTION Revision 1000.2  2004/06/01 20:47:40  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6 * PRODUCTION * =========================================================================== *//*  $Id: browser_config.cpp,v 1000.2 2004/06/01 20:47:40 gouriano Exp $ * =========================================================================== * *                            PUBLIC DOMAIN NOTICE *               National Center for Biotechnology Information * *  This software/database is a "United States Government Work" under the *  terms of the United States Copyright Act.  It was written as part of *  the author's official duties as a United States Government employee and *  thus cannot be copyrighted.  This software/database is freely available *  to the public for use. The National Library of Medicine and the U.S. *  Government have not placed any restriction on its use or reproduction. * *  Although all reasonable efforts have been taken to ensure the accuracy *  and reliability of the software and data, the NLM and the U.S. *  Government do not and cannot warrant the performance or results that *  may be obtained by using this software or data. The NLM and the U.S. *  Government disclaim all warranties, express or implied, including *  warranties of performance, merchantability or fitness for any particular *  purpose. * *  Please cite the author in any work or product based on this material. * * =========================================================================== * * Authors:  Josh Cherry * * File Description:  Configure things so that gbench MIME types *                    launch this copy of gbench * */#include <ncbi_pch.hpp>#include "browser_config.hpp"#ifdef NCBI_OS_MSWIN#include "windows_registry.hpp"#endif#include <corelib/ncbiapp.hpp>#include <gui/objutils/utils.hpp>#include <gui/utils/system_path.hpp>BEGIN_NCBI_SCOPE#ifdef NCBI_OS_MSWIN// Set the appropriate Windows registry variables.// class_name is just a name that gets used in the registry;// something like "gbench.asntext" seems appropriate.static void s_RegisterMimeType(EHkey root_key, const string& mime_type,                               const string& extension,                               const string& command_line,                               const string& class_name,                               const string& description){        SetWinRegVariable(root_key,         "Software\\CLASSES\\MIME\\Database\\Content Type\\" + mime_type,        "Extension", extension);            SetWinRegVariable(root_key,         "Software\\CLASSES\\" + class_name,        "", description);        SetWinRegVariable(root_key,         "Software\\CLASSES\\" + class_name + "\\shell",        "", "open");        SetWinRegVariable(root_key,         "Software\\CLASSES\\" + class_name + "\\shell\\open",        "", "open");        SetWinRegVariable(root_key,         "Software\\CLASSES\\" + class_name + "\\shell\\open\\command",        "", command_line);            SetWinRegVariable(root_key,         "Software\\CLASSES\\" + extension,        "", class_name);        SetWinRegVariable(root_key,         "Software\\CLASSES\\" + extension,        "Content Type", mime_type);        SetWinRegVariable(root_key,         "Software\\CLASSES\\" + extension + "\\" + class_name,        "", "");        SetWinRegVariable(root_key,         "Software\\CLASSES\\" + extension + "\\" + class_name + "\\ShellNew",        "", "");    }#endif  // NCBI_OS_MSWIN// For windows, set a bunch of stuff in the registry.  Both IE and// Netscape/Mozilla look at this.// We associate each MIME type of interest with a file name extension,// and associate each file name extension with a command line// involving gbench.void GBenchBrowserConfig(bool whole_machine, bool remote){#ifdef NCBI_OS_MSWIN    CNcbiApplication* app = CNcbiApplication::Instance();    _ASSERT(app);	// enclose the path name in quotes	string gbench_exe = "\"" + app->GetArguments().GetProgramName() + "\"";    if (remote) {        gbench_exe += " -remote";    } else {        gbench_exe += " -noremote";    }	EHkey root_key;    if (whole_machine) {        root_key = eHkey_local_machine;    } else {        root_key = eHkey_current_user;    }    s_RegisterMimeType(root_key, "application/x-gbench",        ".gbench", gbench_exe + " -t auto \"%1\"", "gbench.auto",        "Genome Workbench input file");        s_RegisterMimeType(root_key, "application/x-gbench-asntext",        ".gbasntx", gbench_exe + " -t asntext \"%1\"", "gbench.asntext",        "Genome Workbench ASN.1 text");        s_RegisterMimeType(root_key, "application/x-gbench-asnbin",        ".gbasnbn", gbench_exe + " -t asnbin \"%1\"", "gbench.asnbin",        "Genome Workbench ASN.1 binary");        s_RegisterMimeType(root_key, "application/x-gbench-xml",        ".gbxml", gbench_exe + " -t xml \"%1\"", "gbench.xml",        "Genome Workbench XML");        s_RegisterMimeType(root_key, "application/x-gbench-fasta",        ".gbfasta", gbench_exe + " -t fasta \"%1\"", "gbench.fasta",        "Genome Workbench FASTA format file");        s_RegisterMimeType(root_key, "application/x-gbench-newick",        ".gbnewic", gbench_exe + " -t newick \"%1\"", "gbench.newick",        "Genome Workbench Newick format tree file");        s_RegisterMimeType(root_key, "application/x-gbench-textalign",        ".gbtxaln", gbench_exe + " -t textalign \"%1\"", "gbench.textalign",        "Genome Workbench text format sequence alignment");#else  // some kind of unix    // For unix we'll just manipulate the user's .mailcap file.    // Netscape/Mozilla looks at this.  Unfortunately Opera and    // Konqueror don't.    string mailcap_path = CDir::GetHome() + ".mailcap";    CFile orig_mailcap_file(mailcap_path);    bool orig_mailcap_exists = orig_mailcap_file.Exists();    if (orig_mailcap_exists) {        orig_mailcap_file.Rename(orig_mailcap_file.GetPath()            + "-gbench-backup");    }    CNcbiOfstream new_mailcap(mailcap_path.c_str());    if (orig_mailcap_exists) {        CNcbiIfstream orig_mailcap(orig_mailcap_file.GetPath().c_str());        string line;        while (getline(orig_mailcap, line)) {            if (!NStr::StartsWith(line, "application/x-gbench",                NStr::eNocase)) {                new_mailcap << line << '\n';            }        }    }        static const string sc_Types[] = {"asntext", "asnbin", "xml", "newick",        "textalign", "fasta"};        string bin_dir = CSystemPath::GetStdPath() + "/bin/";    string remoteness;    if (remote) {        remoteness = "remote";    } else {        remoteness = "noremote";    }    new_mailcap << "application/x-gbench; "                << bin_dir << "gbench_" << remoteness << "_auto %s" << '\n';    for (unsigned int i = 0;    i < sizeof(sc_Types) / sizeof(string);  ++i) {        new_mailcap << "application/x-gbench-" << sc_Types[i] << "; "            << bin_dir << "gbench_" << remoteness << "_" << sc_Types[i]            << " %s" << '\n';    }#endif}END_NCBI_SCOPE/* * =========================================================================== * $Log: browser_config.cpp,v $ * Revision 1000.2  2004/06/01 20:47:40  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6 * * Revision 1.6  2004/05/21 22:27:42  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.5  2004/05/03 13:01:25  dicuccio * gui/utils --> gui/objutils where needed * * Revision 1.4  2004/04/12 20:16:29  jcherry * Support "noremote" configuration option for unix too * * Revision 1.3  2004/04/12 18:14:31  dicuccio * Made browser config API standard on all platforms. * * Revision 1.2  2004/04/09 17:24:47  jcherry * Implemented browser configuration for Windows, and changed how * it works on unix for consistency * * Revision 1.1  2004/04/07 21:04:10  jcherry * Initial version * * =========================================================================== */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -