Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 23, 2006, 4:07:41 PM (18 years ago)
Author:
bensch
Message:

netlink quite nice

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/util/filesys/net_link.cc

    r9393 r9394  
     1/*
     2   orxonox - the future of 3D-vertical-scrollers
    13
     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*/
    215
    316#include "net_link.h"
     17#include "debug.h"
    418
    5 
    6 #include "threading.h"
    7 void SimpleGameMenu::execURL() const
    8 {
    9   std::string URL = "http://www.orxonox.net";
    10   SDL_CreateThread(startURL, (void*)&URL);
    11 }
    1219
    1320#ifdef __OSX__
     
    1724#endif
    1825
    19 int SimpleGameMenu::startURL(void* url)
     26
     27NetLink::NetLink(const std::string& linkName)
    2028{
     29  this->_link = linkName;
     30}
     31
     32
     33void NetLink::openInBrowser() const
     34{
     35  SDL_CreateThread(NetLink::openupInBrowser, (void*)&this->_link);
     36}
     37
     38OrxThread::Mutex NetLink::_mutex;
     39std::string NetLink::_browser = "firefox";
     40std::list<std::string> NetLink::_browserList = NetLink::buildBrowserList();
     41
     42
     43
     44
     45int NetLink::openupInBrowser(void* url)
     46{
     47  OrxThread::MutexLock lock(&NetLink::_mutex);
     48
    2149  std::string URL = *(std::string*)url;
    2250#ifdef __linux__
    23   system ((std::string("firefox ") + URL).c_str());
     51  system ((std::string(NetLink::defaultBrowser()) + " " + URL).c_str());
     52
    2453#elif defined __OSX__
    2554  CFURLRef url_handle = CFURLCreateWithBytes (NULL, (UInt8 *)URL.c_str(), URL.size(),
     
    2756  LSOpenCFURLRef (url_handle, NULL);
    2857  CFRelease (url_handle);
     58
    2959#elif defined __WIN32__
    3060  /*  ShellExecute(GetActiveWindow(),
     
    3363#endif
    3464  PRINTF(3)("loaded external webpage %s\n", URL.c_str());
     65
     66  return 0;
    3567}
    3668
     69void NetLink::setDefaultBrowser(const std::string& browserName)
     70{
     71  OrxThread::MutexLock lock(&NetLink::_mutex);
     72  NetLink::_browser = browserName;
     73}
     74
     75std::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}
Note: See TracChangeset for help on using the changeset viewer.