~ubuntu-branches/ubuntu/precise/amule-adunanza/precise

« back to all changes in this revision

Viewing changes to src/webserver/src/WebInterface.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-02-18 21:16:23 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100218211623-gptwe60zx1knfkmu
Tags: 2010.1+2.2.6-0ubuntu1
* New upstream release (LP: #524697)
  - Drop manpages_spelling_fixes.diff fixed by upstream
  - Drop cryptopp-reference.diff fixed by upstream
  - Bump Standards-Version no changes required
  - Update install files (amule -> amuleadunanza)
  - debian/rules: amule.xpm -> amuleadunanza.xpm
  - Add README.Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
2
// This file is part of the aMule Project.
3
3
//  
4
 
// Copyright (c) 2004-2008 shakraw ( shakraw@users.sourceforge.net )
5
 
// Copyright (c) 2003-2008 Kry ( elkry@sourceforge.net / http://www.amule.org )
6
 
// Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
 
4
// Copyright (c) 2004-2009 shakraw ( shakraw@users.sourceforge.net )
 
5
// Copyright (c) 2003-2009 Kry ( elkry@sourceforge.net / http://www.amule.org )
 
6
// Copyright (c) 2003-2009 aMule Team ( admin@amule.org / http://www.amule.org )
7
7
//
8
8
// Any parts of this program derived from the xMule, lMule or eMule project,
9
9
// or contributed by third-party developers are copyrighted by their
35
35
#ifdef __WXMAC__
36
36
        #include <CoreFoundation/CFBundle.h> // Do_not_auto_remove
37
37
        #include <ApplicationServices/ApplicationServices.h> // Do_not_auto_remove
 
38
// ADUNANZA BEGIN
 
39
// Per wxWidgets 2.9.x e Snow Leopard
 
40
#if 0
38
41
        #include <wx/mac/corefoundation/cfstring.h> // Do_not_auto_remove
 
42
#else
 
43
 
 
44
        #if wxCHECK_VERSION(2, 9, 0)
 
45
                #include <wx/osx/core/cfstring.h>  // Do_not_auto_remove
 
46
        #else
 
47
                #include <wx/mac/corefoundation/cfstring.h>  // Do_not_auto_remove
 
48
        #endif
 
49
 
 
50
#endif
 
51
// ADUNANZA END
 
52
 
 
53
 
39
54
#endif
40
55
 
41
56
#include <ec/cpp/ECFileConfig.h>        // Needed for CECFileConfig
50
65
#       include <libintl.h>
51
66
#endif
52
67
 
 
68
// ADUNANZA BEGIN
 
69
#include "AdunanzA.h"
 
70
// ADUNANZA END
 
71
 
 
72
// ADUNANZA BEGIN
 
73
// Per wxWidgets 2.9.x e Snow Leopard
 
74
 
 
75
#ifdef AMULEWEB28
 
76
 
 
77
// ADUNANZA END
 
78
 
 
79
 
53
80
 
54
81
/*
55
82
 * Socket handling in wxBase (same as amuled)
92
119
        return;
93
120
    }
94
121
 
95
 
    wxASSERT( (fd > 2) && (fd < FD_SETSIZE) );
 
122
    wxASSERT( (fd >= 0) && (fd < FD_SETSIZE) );
96
123
    
97
124
    if ( m_gsocks[fd] ) {
98
125
        return;
113
140
        return;
114
141
    }
115
142
    
116
 
    wxASSERT( (fd > 2) && (fd < FD_SETSIZE) );
 
143
    wxASSERT( (fd >= 0) && (fd < FD_SETSIZE) );
117
144
    
118
145
    int i = m_fd_idx[fd];
119
146
    if ( i == 0xffff ) {
328
355
}
329
356
 
330
357
 
 
358
// ADUNANZA BEGIN
 
359
// Per wxWidgets 2.9.x e Snow Leopard
 
360
// codice spostato
 
361
#if 0
331
362
 
332
363
//-------------------------------------------------------------------
333
364
IMPLEMENT_APP(CamulewebApp)
335
366
 
336
367
BEGIN_EVENT_TABLE(CamulewebApp, CaMuleExternalConnector)
337
368
END_EVENT_TABLE()
 
369
#endif
 
370
// ADUNANZA END
 
371
 
338
372
 
339
373
CamulewebApp::CamulewebApp() : m_table(new CWebserverGSocketFuncTable)
340
374
{
346
380
        return new CWebserverAppTraits(m_table);
347
381
}
348
382
 
 
383
 
 
384
// ADUNANZA BEGIN
 
385
// Per wxWidgets 2.9.x e Snow Leopard
 
386
 
 
387
 
 
388
#endif
 
389
 
 
390
//-------------------------------------------------------------------
 
391
IMPLEMENT_APP(CamulewebApp)
 
392
//-------------------------------------------------------------------
 
393
 
 
394
 
 
395
BEGIN_EVENT_TABLE(CamulewebApp, CaMuleExternalConnector)
 
396
END_EVENT_TABLE()
 
397
 
 
398
// ADUNANZA END
 
399
 
349
400
void CamulewebApp::Post_Shell() {
350
401
        m_webserver->StopServer();
351
402
        delete m_webserver;
430
481
                                                        absoluteURL,
431
482
                                                        kCFURLPOSIXPathStyle);
432
483
                                        CFRelease(absoluteURL);
 
484
// ADUNANZA BEGIN
 
485
// Per wxWidgets 2.9.x e Snow Leopard
 
486
#if 0
433
487
                                        dir = wxMacCFStringHolder(pathString).
434
488
                                                AsString(wxLocale::GetSystemEncoding());
 
489
#else
 
490
 
 
491
                                        #if wxCHECK_VERSION(2, 9, 0)
 
492
                                                dir = wxCFStringRef(pathString).
 
493
                                                AsString(wxLocale::GetSystemEncoding());
 
494
                                        #else
 
495
                                                dir = wxMacCFStringHolder(pathString).
 
496
                                                AsString(wxLocale::GetSystemEncoding());
 
497
                                        #endif
 
498
 
 
499
 
 
500
#endif
 
501
// ADUNANZA END
435
502
                                        if (CheckDirForTemplate(dir, templateName)) {
436
503
                                                templateDir = dir;
437
504
                                                return true;
458
525
        // Returns 'aMule' when we use 'amule' elsewhere
459
526
        dir = wxStandardPaths::Get().GetDataDir();
460
527
        dir = dir.BeforeLast(wxFileName::GetPathSeparator());
 
528
// ADUNANZA BEGIN
 
529
#if 0
461
530
        dir = JoinPaths(dir, JoinPaths(wxT("amule"), wxT("webserver")));
 
531
#else
 
532
        dir = JoinPaths(dir, JoinPaths(wxT(PACKAGE_ADUNANZA), wxT("webserver")));
 
533
#endif
 
534
// ADUNANZA END
462
535
        if (CheckDirForTemplate(dir, templateName)) {
463
536
                templateDir = dir;
464
537
                return true;
561
634
 
562
635
                if (!(m_TemplateOk = GetTemplateDir(m_TemplateName, m_TemplateDir))) {
563
636
                        // no reason to run webserver without a template
 
637
// ADUNANZA BEGIN
 
638
#if 0
564
639
                        fprintf(stderr, "FATAL ERROR: Cannot find template: %s\n", (const char *)unicode2char(m_TemplateName));
 
640
#else
 
641
                        fprintf(stderr, "FATAL ERROR (1): Cannot find template: %s in dir %s\n",
 
642
                                        (const char *)unicode2char(m_TemplateName),
 
643
                                        (const char *)unicode2char(m_TemplateDir));
 
644
#endif
 
645
// ADUNANZA END
565
646
                        return true;
566
647
                }
567
648
                m_Verbose = false;
582
663
                }
583
664
                if (!(m_TemplateOk = GetTemplateDir(m_TemplateName, m_TemplateDir))) {
584
665
                        // no reason to run webserver without a template
 
666
// ADUNANZA BEGIN
 
667
#if 0
585
668
                        fprintf(stderr, "FATAL ERROR: Cannot find template: %s\n", (const char *)unicode2char(m_TemplateName));
 
669
#else
 
670
                        fprintf(stderr, "FATAL ERROR (2): Cannot find template: %s in dir %s\n",
 
671
                                        (const char *)unicode2char(m_TemplateName),
 
672
                                        (const char *)unicode2char(m_TemplateDir));
 
673
#endif
 
674
// ADUNANZA END
586
675
                        return true;
587
676
                }
588
677
 
635
724
 
636
725
const wxString CamulewebApp::GetGreetingTitle()
637
726
{
 
727
// ADUNANZA BEGIN
 
728
#if 0   
638
729
        return _("aMule Web Server");
 
730
#else
 
731
        return _("aMule AdunanzA Web Server");
 
732
#endif
 
733
// ADUNANZA END
639
734
}
640
735
 
641
736
void CamulewebApp::Pre_Shell() {
650
745
 
651
746
void CamulewebApp::TextShell(const wxString &)
652
747
{
 
748
// ADUNANZA BEGIN
 
749
// Per wxWidgets 2.9.x e Snow Leopard
 
750
#ifdef AMULEWEB28
 
751
// ADUNANZA END
653
752
        while ( true ) {
654
753
                m_table->RunSelect();
655
754
                ProcessPendingEvents();
656
755
                ((CWebserverAppTraits *)GetTraits())->DeletePending();
657
756
        }
 
757
// ADUNANZA BEGIN
 
758
// Per wxWidgets 2.9.x e Snow Leopard
 
759
#else
 
760
 
 
761
#ifndef AMULEWEB_DUMMY
 
762
        wxApp::OnRun();
 
763
#endif
 
764
 
 
765
#endif
 
766
// ADUNANZA END
 
767
 
658
768
}
659
769
 
660
770
void CamulewebApp::LoadAmuleConfig(CECFileConfig& cfg)
664
774
        m_AllowGuest = (cfg.Read(wxT("/WebServer/UseLowRightsUser"), 0l) == 1l);
665
775
        cfg.ReadHash(wxT("/WebServer/Password"), &m_AdminPass);
666
776
        cfg.ReadHash(wxT("/WebServer/PasswordLow"), &m_GuestPass);
667
 
        m_WebserverPort = cfg.Read(wxT("/WebServer/Port"), -1l);
 
777
        m_WebserverPort = cfg.Read(wxT("/WebServer/Port"), 4711l);
668
778
        m_UPnPWebServerEnabled =
669
779
                (cfg.Read(wxT("/Webserver/UPnPWebServerEnabled"), 0l) == 1l);
670
780
        m_UPnPTCPPort = cfg.Read(wxT("/WebServer/UPnPTCPPort"), 50001l);
677
787
        CaMuleExternalConnector::LoadConfigFile();
678
788
        if (m_configFile) {
679
789
                wxString tmp;
680
 
                m_WebserverPort = m_configFile->Read(wxT("/Webserver/Port"), -1l);
 
790
                m_WebserverPort = m_configFile->Read(wxT("/Webserver/Port"), 4711l);
681
791
                m_configFile->Read(wxT("/Webserver/UPnPWebServerEnabled"),
682
792
                        &m_UPnPWebServerEnabled, false);
683
793
                m_UPnPTCPPort = m_configFile->Read(wxT("/WebServer/UPnPTCPPort"), 50001l);