Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

merged cleanup into trunk (only improvements)

File size: 2.0 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
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
16#include "net_link.h"
17#include "debug.h"
18
19#include "threads/mutex_locker.h"
20
21#ifdef __OSX__
22#include <ApplicationServices/ApplicationServices.h>
23#elif defined __WIN32__
24//#include <shellapi.h>
25#endif
26
27
28NetLink::NetLink(const std::string& linkName)
29{
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;
40std::string NetLink::_defaultBrowser = "firefox";
41std::list<std::string> NetLink::_browserList = NetLink::buildBrowserList();
42
43
44
45
46int NetLink::openupInBrowser(void* url)
47{
48  OrxThread::MutexLocker lock(&NetLink::_mutex);
49
50  std::string URL = *(std::string*)url;
51#ifdef __linux__
52  system ((std::string(NetLink::defaultBrowser()) + " " + URL).c_str());
53
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);
59
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());
66
67  return 0;
68}
69
70void NetLink::setDefaultBrowser(const std::string& browserName)
71{
72  OrxThread::MutexLocker lock(&NetLink::_mutex);
73  NetLink::_defaultBrowser = browserName;
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.