- Timestamp:
- Jul 23, 2006, 4:07:41 PM (18 years ago)
- Location:
- branches/proxy/src/lib/util
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/util/Makefile.am
r9347 r9394 23 23 filesys/file.cc \ 24 24 filesys/directory.cc \ 25 filesys/net_link.cc \ 25 26 \ 26 27 preferences.cc \ … … 42 43 filesys/file.h \ 43 44 filesys/directory.h \ 45 filesys/net_link.h \ 44 46 \ 45 47 preferences.h \ -
branches/proxy/src/lib/util/filesys/net_link.cc
r9393 r9394 1 /* 2 orxonox - the future of 3D-vertical-scrollers 1 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 */ 2 15 3 16 #include "net_link.h" 17 #include "debug.h" 4 18 5 6 #include "threading.h"7 void SimpleGameMenu::execURL() const8 {9 std::string URL = "http://www.orxonox.net";10 SDL_CreateThread(startURL, (void*)&URL);11 }12 19 13 20 #ifdef __OSX__ … … 17 24 #endif 18 25 19 int SimpleGameMenu::startURL(void* url) 26 27 NetLink::NetLink(const std::string& linkName) 20 28 { 29 this->_link = linkName; 30 } 31 32 33 void NetLink::openInBrowser() const 34 { 35 SDL_CreateThread(NetLink::openupInBrowser, (void*)&this->_link); 36 } 37 38 OrxThread::Mutex NetLink::_mutex; 39 std::string NetLink::_browser = "firefox"; 40 std::list<std::string> NetLink::_browserList = NetLink::buildBrowserList(); 41 42 43 44 45 int NetLink::openupInBrowser(void* url) 46 { 47 OrxThread::MutexLock lock(&NetLink::_mutex); 48 21 49 std::string URL = *(std::string*)url; 22 50 #ifdef __linux__ 23 system ((std::string("firefox ") + URL).c_str()); 51 system ((std::string(NetLink::defaultBrowser()) + " " + URL).c_str()); 52 24 53 #elif defined __OSX__ 25 54 CFURLRef url_handle = CFURLCreateWithBytes (NULL, (UInt8 *)URL.c_str(), URL.size(), … … 27 56 LSOpenCFURLRef (url_handle, NULL); 28 57 CFRelease (url_handle); 58 29 59 #elif defined __WIN32__ 30 60 /* ShellExecute(GetActiveWindow(), … … 33 63 #endif 34 64 PRINTF(3)("loaded external webpage %s\n", URL.c_str()); 65 66 return 0; 35 67 } 36 68 69 void NetLink::setDefaultBrowser(const std::string& browserName) 70 { 71 OrxThread::MutexLock lock(&NetLink::_mutex); 72 NetLink::_browser = browserName; 73 } 74 75 std::list<std::string> NetLink::buildBrowserList() 76 { 77 std::list<std::string> browserList; 78 browserList.push_back("firefox"); 79 browserList.push_back("mozilla"); 80 browserList.push_back("konqueror"); 81 82 return browserList; 83 } -
branches/proxy/src/lib/util/filesys/net_link.h
r9393 r9394 1 /*! 2 * @file net_link.h 3 * @brief Definition of a NetLink class 4 * NetLink is a File link to a page of file link to the Internet, 5 * or the local file-system 6 * 7 * Opening a link should be made easy through this class 8 * 9 * !! DANGER IT IS POSSIBLE TO EXECUTE ALL PROGRAMMS WITH USER'S RIGHTS 10 * !! ON THE DESIGNATED MACHINE 11 * !! THIS CLASS SHOULD BE USED WITH CAUTION WHEN USING OVER IN NETWORK 12 * !! MODE 13 */ 1 14 2 15 #ifndef __NET_LINK_H__ … … 6 19 #include <list> 7 20 21 #include "threading.h" 22 23 //! NetLink is a File and Link executer for Internet Links 24 /** 25 * @example: NetLink("http://www.orxonox.net").openInBrowser(); 26 */ 8 27 class NetLink 9 28 { 10 29 public: 11 NetLink(const std::string& );30 NetLink(const std::string& linkName); 12 31 13 void execURL() const; 14 int startURL(void* url); 15 32 void openInBrowser() const; 16 33 17 34 static void setDefaultBrowser(const std::string& browserName); 18 static const std::string& defaultBrowser() ;35 static const std::string& defaultBrowser() { return NetLink::_browser; }; 19 36 20 37 private: 21 static void buildBrowserList(); 38 static int openupInBrowser(void* url); 39 40 static std::list<std::string> buildBrowserList(); 22 41 23 42 24 43 private: 25 std::string _link; 44 std::string _link; //!< Linkname 45 26 46 27 47 // static lists. 48 static OrxThread::Mutex _mutex; //!< One mutex to lock them all. 28 49 static std::string _browser; 29 50 static std::list<std::string> _browserList;
Note: See TracChangeset
for help on using the changeset viewer.