44 #if defined(NCBI_OS_MAC) || defined(NCBI_OS_DARWIN)
45 # ifdef NCBI_COMPILER_METROWERKS
46 # define __NOEXTENSIONS__
48 # include <ApplicationServices/ApplicationServices.h>
96 strm <<
"Unrecognized file type";
134 <<
"CAppRegistry::Find(): no application associated with type "
161 #elif defined(NCBI_OS_DARWIN)
164 OSErr err = FSPathMakeRef((
const UInt8 *)
file.c_str(), &fileRef,
NULL);
166 err = LSOpenFSRef(&fileRef,
NULL);
168 return (err == noErr);
173 const string&
prog = ai->GetExePath();
174 const string app(
prog +
" " +
file);
183 _TRACE(
Info <<
"CAppPopup::PopupURL: opening URL: " << url);
193 reinterpret_cast<int>(ShellExecute(
NULL,
201 #elif defined(NCBI_OS_DARWIN)
205 CFURLRef urlRef = CFURLCreateWithBytes(kCFAllocatorDefault,
206 (
const UInt8 *) url.c_str(),
208 kCFStringEncodingMacRoman,
211 const OSErr err = LSOpenCFURLRef(urlRef,
NULL);
212 return (err == noErr);
214 #elif defined(NCBI_OS_UNIX)
219 string std_in, std_out, std_err;
223 vector<string> programs;
224 programs.push_back(
"firefox");
225 programs.push_back(
"mozilla");
226 programs.push_back(
"netscape");
229 args.push_back(
"-remote");
230 string arg =
"openURL(" + url +
",new-window)";
232 ITERATE (vector<string>, program, programs) {
234 std_in, std_out, std_err);
235 if (!exit_status && std_err.empty()) {
240 ITERATE (vector<string>, program, programs) {
244 catch(
const std::exception&)
class CAppInfo defines an interface for application registration information
class CAppRegistry defines the registry of application information for automated application link-out...
container_type::const_iterator const_iterator
const_iterator end() const
const_iterator find(const key_type &key) const
CNcbiOstream & operator<<(CNcbiOstream &out, const CEquivRange &range)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
void Warning(CExceptionArgs_Base &args)
void Info(CExceptionArgs_Base &args)
static TExitCode System(const char *cmdline)
Execute the specified command.
static CResult SpawnLP(EMode mode, const char *cmdname, const char *argv,...)
Spawn a new process with variable number of command-line arguments and find file to execute from the ...
@ eDetach
Like eNoWait, continues to execute calling process; new process is run in background with no access t...
TAppInfoRef & operator[](const TFileType &type)
filetype::TFileType TFileType
filetype::TFileType TFileType
static int Exec(const string &cmd, const vector< string > &args, const string &std_in, string &std_out, string &std_err, STimeout *timeout=0)
Run an executable using strings for std* .
const string & GetExePath(void) const
static CAppRegistry m_Registry
CAppInfo(const string &path=kEmptyStr)
static bool PopupFile(const string &file, TFileType filetype=filetype::eUnknown)
launch an application to handle a file
const TAppInfoRef & Find(TFileType filetype) const
static bool PopupURL(const string &url)
launch an application to handle a URL
static CAppRegistry & GetRegistry(void)
retrieve the application registry
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Defines a portable execute class.