~ubuntu-branches/ubuntu/intrepid/notecase/intrepid

« back to all changes in this revision

Viewing changes to src/_unx/ExecuteFile.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mitsuya Shibata
  • Date: 2008-02-10 09:56:36 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080210095636-n7dpodksxxxjrrar
Tags: 1.7.9-0ubuntu1
* New Upstream Release (LP: #190582)
* Keboard shortcuts already work in previous version (LP: #137466)
* Node Title Bar function  already work too (LP: #185985)

Show diffs side-by-side

added added

removed removed

Lines of Context:
424
424
                strURI = uri.ToString();
425
425
        }
426
426
 
427
 
        if (mimeType.empty())
428
 
        {
429
 
 
430
 
            TRACE("2: Mime type using heuristic: %s\n", mimeType.c_str());
431
 
        }
432
 
 
433
427
        TRACE("Open path:%s - URI:%s, mime type:%s\n", path.c_str(), strURI.c_str(), mimeType.c_str());
434
428
        if (!mimeType.empty())
435
429
        {
453
447
                g_bMimeMapsLoaded = true;
454
448
        }
455
449
 
456
 
        std::string strExt = GetFileExt(path.c_str());
457
 
        if(!strExt.empty()) strExt = strExt.substr(1); // strip "."
458
 
        if(!strExt.empty()){
459
 
                TRACE("Ext: %s\n", strExt.c_str());
460
 
                std::string strMime = g_mapExt2Mime[strExt];
461
 
                if(!strMime.empty()){
 
450
        std::string strMime;
 
451
        // first try heuristic - http link would crash in GetMimeType 
 
452
            if (path.substr(0, 7) == "http://")
 
453
                strMime = "text/html";
 
454
            else if (path.substr(0, 8) == "https://")
 
455
                strMime = "text/html";
 
456
            else if (path.substr(0, 6) == "ftp://")
 
457
                strMime = "text/html";
 
458
            else if (path.substr(0, 7) == "mailto:")
 
459
                strMime = "message/rfc822";
 
460
        else{ 
 
461
                std::string strExt = GetFileExt(path.c_str());
 
462
                if(!strExt.empty()) strExt = strExt.substr(1); // strip "."
 
463
                if(!strExt.empty()){
 
464
                        TRACE("Ext: %s\n", strExt.c_str());
 
465
                        strMime = g_mapExt2Mime[strExt];
 
466
                }
 
467
        }
 
468
        
 
469
        if(!strMime.empty()){
462
470
                        TRACE("Mime: %s\n", strMime.c_str());
463
471
                        std::string strProg = g_mapMime2Prog[strMime];
464
472
                        if(strProg.empty()){
480
488
                                TRACE("Exec: %s\n", szBuffer);
481
489
                                return g_spawn_command_line_async(szBuffer, 0); // TOFIX from utf8?
482
490
                        }
483
 
                }
484
491
        }
485
492
 
486
493
        return g_spawn_command_line_async(FileNameFromUTF8(path).c_str(), 0);