Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/util/filesys/net_link.cc @ 10765

Last change on this file since 10765 was 10618, checked in by bknecht, 18 years ago

merged cleanup into trunk (only improvements)

File size: 2.0 KB
RevLine 
[9394]1/*
2   orxonox - the future of 3D-vertical-scrollers
[9393]3
[9394]4   Copyright (C) 2004 orx
[9393]5
[9394]6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14*/
15
[9393]16#include "net_link.h"
[9394]17#include "debug.h"
[9393]18
[10618]19#include "threads/mutex_locker.h"
[9393]20
21#ifdef __OSX__
22#include <ApplicationServices/ApplicationServices.h>
23#elif defined __WIN32__
24//#include <shellapi.h>
25#endif
26
[9394]27
28NetLink::NetLink(const std::string& linkName)
[9393]29{
[9394]30  this->_link = linkName;
31}
32
33
34void NetLink::openInBrowser() const
35{
36  SDL_CreateThread(NetLink::openupInBrowser, (void*)&this->_link);
37}
38
39OrxThread::Mutex NetLink::_mutex;
[9395]40std::string NetLink::_defaultBrowser = "firefox";
[9394]41std::list<std::string> NetLink::_browserList = NetLink::buildBrowserList();
42
43
44
45
46int NetLink::openupInBrowser(void* url)
47{
[10618]48  OrxThread::MutexLocker lock(&NetLink::_mutex);
[9394]49
[9393]50  std::string URL = *(std::string*)url;
51#ifdef __linux__
[9394]52  system ((std::string(NetLink::defaultBrowser()) + " " + URL).c_str());
53
[9393]54#elif defined __OSX__
55  CFURLRef url_handle = CFURLCreateWithBytes (NULL, (UInt8 *)URL.c_str(), URL.size(),
56                                              kCFStringEncodingASCII, NULL);
57  LSOpenCFURLRef (url_handle, NULL);
58  CFRelease (url_handle);
[9394]59
[9393]60#elif defined __WIN32__
61  /*  ShellExecute(GetActiveWindow(),
62               "open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL);
63}*/
64#endif
65  PRINTF(3)("loaded external webpage %s\n", URL.c_str());
[9394]66
67  return 0;
[9393]68}
69
[9394]70void NetLink::setDefaultBrowser(const std::string& browserName)
71{
[10618]72  OrxThread::MutexLocker lock(&NetLink::_mutex);
[9395]73  NetLink::_defaultBrowser = browserName;
[9394]74}
75
76std::list<std::string> NetLink::buildBrowserList()
77{
78  std::list<std::string> browserList;
79  browserList.push_back("firefox");
80  browserList.push_back("mozilla");
81  browserList.push_back("konqueror");
82
83  return  browserList;
84}
Note: See TracBrowser for help on using the repository browser.