Changeset 1644

Show
Ignore:
Timestamp:
06/27/08 17:37:47 (2 months ago)
Author:
xkovah
Message:

It works with the globVisitor kludge, and I still don't understand why the notifyListeners method isn't working…

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • capture-mod/trunk/ApplicationPlugins/InternetExplorer/Application_InternetExplorer.vcproj

    r823 r1644  
    6565                AdditionalDependencies="comsuppw.lib Version.lib Advapi32.lib" 
    6666                LinkIncremental="2" 
    67                 AdditionalLibraryDirectories=""D:\Microsoft Platform SDK for Windows Server 2003 R2\Lib"" 
     67                AdditionalLibraryDirectories="F:\WinDDK\6000\lib\wxp\i386;"D:\Microsoft Platform SDK for Windows Server 2003 R2\Lib"" 
    6868                GenerateDebugInformation="true" 
    6969                SubSystem="1" 
  • capture-mod/trunk/ApplicationPlugins/InternetExplorer/InternetExplorerInstance.h

    r823 r1644  
    2525    /* Below are various methods we must implement for DWebBrowserEvents. 
    2626       Just ignore most of them as they are just stubs. The important ones 
    27        are implemented in Application_InternetExplorer.cpp */ 
     27       are implemented in Application_InternetExplorer.cpp  
     28    XENO: To be clear, the things below are actually IUnknown or IDispatch methods*/ 
    2829    HRESULT STDMETHODCALLTYPE QueryInterface(  
    2930                /* [in] */ REFIID riid, 
  • capture-mod/trunk/CaptureClient.cpp

    r1586 r1644  
    5050 
    5151        hStopRunning = CreateEvent(NULL, FALSE, FALSE, NULL); 
    52         //XENO - Right here, set up the standalone SOAP server 
    53         MySoapServer a = MySoapServer(); 
    5452 
    5553        wstring serverIp = OptionsManager::getInstance()->getOption(L"server"); 
     
    6361        /* Start running the Capture Client */ 
    6462        visitor = new Visitor(); 
    65         printf("entering analyzer\n"); 
    66         analyzer =  new Analyzer(visitor, server); 
     63        //Set up the standalone SOAP server 
     64        MySoapServer a = MySoapServer(visitor); 
     65        analyzer = new Analyzer(visitor, server); 
    6766        Thread* captureClientThread = new Thread(this); 
    6867        captureClientThread->start("CaptureClient"); 
  • capture-mod/trunk/CaptureClient.sln

    r823 r1644  
    1717    GlobalSection(ProjectConfigurationPlatforms) = postSolution 
    1818        {4A258E9F-0B4B-40EF-B6C6-E69C630E5CAC}.Debug|Win32.ActiveCfg = Debug|Win32 
    19         {4A258E9F-0B4B-40EF-B6C6-E69C630E5CAC}.Debug|Win32.Build.0 = Debug|Win32 
    2019        {4A258E9F-0B4B-40EF-B6C6-E69C630E5CAC}.Release|Win32.ActiveCfg = Release|Win32 
    2120        {4A258E9F-0B4B-40EF-B6C6-E69C630E5CAC}.Release|Win32.Build.0 = Release|Win32 
    2221        {AE2C8E80-7D21-47AD-987B-43E0708AE549}.Debug|Win32.ActiveCfg = Debug|Win32 
    23         {AE2C8E80-7D21-47AD-987B-43E0708AE549}.Debug|Win32.Build.0 = Debug|Win32 
    2422        {AE2C8E80-7D21-47AD-987B-43E0708AE549}.Release|Win32.ActiveCfg = Release|Win32 
    2523        {AE2C8E80-7D21-47AD-987B-43E0708AE549}.Release|Win32.Build.0 = Release|Win32 
    2624        {4EF34E6D-B30C-46E5-9FC5-967ECEADE2CD}.Debug|Win32.ActiveCfg = Debug|Win32 
    27         {4EF34E6D-B30C-46E5-9FC5-967ECEADE2CD}.Debug|Win32.Build.0 = Debug|Win32 
    2825        {4EF34E6D-B30C-46E5-9FC5-967ECEADE2CD}.Release|Win32.ActiveCfg = Release|Win32 
    2926        {4EF34E6D-B30C-46E5-9FC5-967ECEADE2CD}.Release|Win32.Build.0 = Release|Win32 
    3027        {C57EC146-60B3-499B-BDFA-5BB5504FDB89}.Debug|Win32.ActiveCfg = Debug|Win32 
    31         {C57EC146-60B3-499B-BDFA-5BB5504FDB89}.Debug|Win32.Build.0 = Debug|Win32 
    3228        {C57EC146-60B3-499B-BDFA-5BB5504FDB89}.Release|Win32.ActiveCfg = Release|Win32 
    3329        {C57EC146-60B3-499B-BDFA-5BB5504FDB89}.Release|Win32.Build.0 = Release|Win32 
  • capture-mod/trunk/CaptureClient.vcproj

    r1586 r1644  
    122122                Name="VCCLCompilerTool" 
    123123                Optimization="3" 
    124                 AdditionalIncludeDirectories="D:\WpdPack\Include;D:\expatpp\src_pp;D:\WinDDK\6000\inc;D:\boost\boost_1_34_0;D:\expatpp\expat\lib;"D:\Microsoft Platform SDK for Windows Server 2003 R2\Include"" 
     124                AdditionalIncludeDirectories="F:\Boost;"F:\Program Files\Microsoft Platform SDK\Include";F:\WinDDK\6000\inc\api;"F:\capture-mod\expatpp\src_pp";"F:\capture-mod\expatpp\expat\lib";"F:\capture-mod\WpdPack_4_0_1\WpdPack\Include"" 
    125125                PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" 
    126126                RuntimeLibrary="2" 
     
    144144                AdditionalDependencies="kernel32.lib Ws2_32.lib Advapi32.lib Psapi.lib fltLib.lib shlwapi.lib expatpp.lib shell32.lib Urlmon.lib $(NOINHERIT)" 
    145145                LinkIncremental="1" 
    146                 AdditionalLibraryDirectories="D:\WinDDK\6000\lib\wxp\i386;D:\expatpp\vc_pp\expatpp\ReleaseMTDLL;"D:\Microsoft Platform SDK for Windows Server 2003 R2\Lib";D:\boost\boost_1_34_0\lib
     146                AdditionalLibraryDirectories="F:\boost_1_34_0\lib;"F:\Program Files\Microsoft Platform SDK\Lib";F:\WinDDK\6000\lib\wxp\i386;"F:\capture-mod\expatpp\expat\lib";"F:\capture-mod\expatpp\vc_pp\expatpp\ReleaseMT"
    147147                GenerateDebugInformation="true" 
    148148                SubSystem="1" 
  • capture-mod/trunk/EventController.cpp

    r823 r1644  
    5151EventController::notifyListeners() 
    5252{ 
     53    if(pCurrentElement != NULL) 
     54    { 
     55        stdext::hash_map<wstring, signal_serverEvent*>::iterator it; 
     56        it = onServerEventMap.find(pCurrentElement->name); 
     57        if(it != onServerEventMap.end()) 
     58        { 
     59            signal_serverEvent* signal_onServerEvent = it->second; 
     60            (*signal_onServerEvent)(pCurrentElement); 
     61        }    
     62        if(pCurrentElement->data != NULL) 
     63        { 
     64            free(pCurrentElement->data); 
     65        } 
     66        delete pCurrentElement; 
     67        pCurrentElement = NULL; 
     68    } 
     69} 
     70 
     71void 
     72EventController::notifyListeners(pElement pInputElement) 
     73{ 
     74 
     75    pCurrentElement = (Element *)pInputElement; 
    5376    if(pCurrentElement != NULL) 
    5477    { 
  • capture-mod/trunk/EventController.h

    r823 r1644  
    7878 
    7979    void receiveServerEvent(const char* xmlDocument); 
     80    void notifyListeners(pElement pInputElement); 
    8081private: 
    8182    static bool instanceCreated; 
  • capture-mod/trunk/MySoapServer.cpp

    r1586 r1644  
    99#include "calculator.nsmap"  
    1010 
    11 MySoapServer::MySoapServer(){ 
    12  
     11#include "Visitor.h" 
     12 
     13Visitor * globVisitor; 
     14 
     15MySoapServer::MySoapServer(Visitor* v){ 
     16 
     17    globVisitor = v; 
    1318    MySoapServerThread = new Thread(this); 
    1419    MySoapServerThread->start("MySoapServer"); 
     
    2530   struct soap soap; 
    2631   SOCKET m, s; // master and slave sockets 
     32 
     33   ///loadClientPlugins(); 
    2734 
    2835   soap_init(&soap); 
     
    5764 
    5865// Implementation of the "add" remote method:  
    59 //int ns__add(struct soap *soap, int a, int b, int &result)  
    6066int ns__add(struct soap *soap, int a, int b, int &result)  
    6167{  
    6268   //printf("add got %d and %d\n", a, b); 
    6369   result = a + b; 
     70 
    6471   return SOAP_OK; 
    6572}  
     73 
     74void MySoapServer::test(){ 
     75 
     76//  printf("myVisitor = %#x\n", MySoapServer::myVisitor); 
     77 
     78} 
    6679 
    6780int ns__ping(struct soap *soap, char * a, char ** result)  
     
    6982   printf("%s\n", a); 
    7083   *result = "pong"; 
     84 
     85    //Build my own new-fangled Element to pass to Visitor:onServerEvent which I think will open  
     86    typedef boost::signal<void (Element*)> signal_serverEvent; 
     87    Attribute att; 
     88    att.name = L"url"; 
     89    att.value = L"http://slashdot.org"; 
     90    Element e; 
     91    e.name = L"iexplore"; 
     92    e.attributes.push_back(att); 
     93    e.data = NULL; 
     94    e.dataLength = 0; 
     95//  printf("trying with notifyListeners\n"); 
     96//  EventController::getInstance()->notifyListeners(&e); 
     97    printf("trying with globVisitor\n"); 
     98    globVisitor->onServerEvent(&e); 
     99 
    71100   return SOAP_OK;  
    72101} 
     
    79108} 
    80109 
     110void 
     111MySoapServer::loadClientPlugins() 
     112{ 
     113    WIN32_FIND_DATA FindFileData; 
     114    HANDLE hFind = INVALID_HANDLE_VALUE; 
     115    wchar_t pluginDirectoryPath[1024]; 
     116 
     117    GetFullPathName(L"plugins\\Application_*.dll", 1024, pluginDirectoryPath, NULL); 
     118    DebugPrint(L"Capture-SOAP Server: Plugin directory - %ls\n", pluginDirectoryPath); 
     119    hFind = FindFirstFile(pluginDirectoryPath, &FindFileData); 
     120 
     121    if (hFind != INVALID_HANDLE_VALUE)  
     122    { 
     123        typedef void (*AppPlugin)(void*); 
     124        do 
     125        { 
     126            wstring pluginDir = L"plugins\\"; 
     127            pluginDir += FindFileData.cFileName;             
     128            HMODULE hPlugin = LoadLibrary(pluginDir.c_str()); 
     129 
     130            if(hPlugin != NULL) 
     131            { 
     132                list<ApplicationPlugin*>* apps = new std::list<ApplicationPlugin*>(); 
     133                applicationPlugins.insert(PluginPair(hPlugin, apps)); 
     134                ApplicationPlugin* applicationPlugin = createApplicationPluginObject(hPlugin); 
     135                if(applicationPlugin == NULL) { 
     136                    FreeLibrary(hPlugin); 
     137                } else { 
     138                    printf("Loaded plugin: %ls\n", FindFileData.cFileName); 
     139                    unsigned int g = applicationPlugin->getPriority(); 
     140                    wchar_t** supportedApplications = applicationPlugin->getSupportedApplicationNames(); 
     141                    for(int i = 0; supportedApplications[i] != NULL; i++) 
     142                    { 
     143                        stdext::hash_map<wstring, ApplicationPlugin*>::iterator it; 
     144                        it = applicationMap.find(supportedApplications[i]); 
     145                        /* Check he application isn't already being handled by a plugin */ 
     146                        if(it != applicationMap.end()) 
     147                        { 
     148                            /* Check the priority of the existing application plugin */ 
     149                            unsigned int p = it->second->getPriority(); 
     150                            if(applicationPlugin->getPriority() > p) 
     151                            { 
     152                                /* Over ride the exisiting plugin if the priority of the loaded one 
     153                                   is greater */ 
     154                                applicationMap.erase(supportedApplications[i]); 
     155                                printf("\toverride: added application: %ls\n", supportedApplications[i]); 
     156                                applicationMap.insert(ApplicationPair(supportedApplications[i], applicationPlugin)); 
     157                            } else { 
     158                                printf("\tplugin overridden: not adding application: %ls\n", supportedApplications[i]); 
     159                            } 
     160                        } else { 
     161                            printf("\tinserted: added application: %ls\n", supportedApplications[i]); 
     162                            applicationMap.insert(ApplicationPair(supportedApplications[i], applicationPlugin));  
     163                        } 
     164                    } 
     165                } 
     166            } 
     167        } while(FindNextFile(hFind, &FindFileData) != 0); 
     168        FindClose(hFind); 
     169    } 
     170     
     171} 
     172 
     173ApplicationPlugin* 
     174MySoapServer::createApplicationPluginObject(HMODULE hPlugin) 
     175{ 
     176    typedef void (*PluginExportInterface)(void*); 
     177    PluginExportInterface pluginCreateInstance = NULL; 
     178    ApplicationPlugin* applicationPlugin = NULL; 
     179    /* Get the function address to create a plugin object */ 
     180    pluginCreateInstance = (PluginExportInterface)GetProcAddress(hPlugin,"New"); 
     181    /* Create a new plugin object in the context of the plugin */ 
     182    pluginCreateInstance(&applicationPlugin); 
     183    /* If the object was created then add it to a list so we can track it */ 
     184    if(applicationPlugin != NULL) 
     185    { 
     186        stdext::hash_map<HMODULE, std::list<ApplicationPlugin*>*>::iterator it; 
     187        it = applicationPlugins.find(hPlugin); 
     188        if(it != applicationPlugins.end()) 
     189        { 
     190            list<ApplicationPlugin*>* apps = it->second; 
     191            apps->push_back(applicationPlugin); 
     192        } 
     193    } 
     194    return applicationPlugin; 
     195} 
     196 
     197void 
     198MySoapServer::onServerEvent(Element* pElement) 
     199{ 
     200    wstring applicationName = L"iexplore"; 
     201    wstring url = L""; 
     202    int time = 30; 
     203    vector<Attribute>::iterator it; 
     204    for(it = pElement->attributes.begin(); it != pElement->attributes.end(); it++) 
     205    { 
     206        if(it->name == L"url") { 
     207            url = it->value; 
     208        } else if(it->name == L"program") { 
     209            applicationName = it->value; 
     210        } else if(it->name == L"time") { 
     211            time = boost::lexical_cast<int>(it->value); 
     212        } 
     213    } 
     214    if(url != L"") 
     215    { 
     216        url = CaptureGlobal::urlDecode(url); 
     217        stdext::hash_map<wstring, ApplicationPlugin*>::iterator vit; 
     218        vit = applicationMap.find(applicationName); 
     219        if(vit != applicationMap.end()) 
     220        { 
     221            ApplicationPlugin* applicationPlugin = vit->second; 
     222            Url* visiturl = new Url(url, applicationName, time); 
     223            DWORD minorErrorCode = 0; 
     224            DWORD majorErrorCode = 0; 
     225            printf("Visiting: %ls -> %ls\n", visiturl->getApplicationName().c_str(), visiturl->getUrl().c_str()); 
     226         
     227            /* Pass the actual visitation process of to the application plugin */ 
     228            majorErrorCode = applicationPlugin->visitUrl(visiturl, &minorErrorCode); 
     229            ///toVisit.push(VisitPair(applicationPlugin, visiturl)); 
     230            ///SetEvent(hQueueNotEmpty); 
     231        } else { 
     232            printf("MySoapServer-onServerEvent: ERROR could not find client %ls path, url not queued for visitation\n", applicationName.c_str()); 
     233        } 
     234    } else { 
     235        printf("MySoapServer-onServerEvent: ERROR no url specified for visit event\n"); 
     236    } 
     237} 
  • capture-mod/trunk/MySoapServer.h

    r1586 r1644  
    33*/ 
    44 
     5#pragma once 
    56#include "captureGSOAP.h" 
    67#include "Thread.h" 
     8 
     9#include "CaptureGlobal.h" 
     10#include <string> 
     11#include <queue> 
     12#include <list> 
     13#include <iostream> 
     14#include <fstream> 
     15#include <vector> 
     16#include <hash_map> 
     17#include <boost/signal.hpp> 
     18#include <boost/bind.hpp> 
     19#include <boost\regex.hpp> 
     20#include <boost/algorithm/string/classification.hpp> 
     21#include <boost/algorithm/string/find_iterator.hpp> 
     22#include <boost/algorithm/string/finder.hpp>  
     23#include <boost/lexical_cast.hpp> 
     24#include <boost/tokenizer.hpp> 
     25#include "Url.h" 
     26#include "ApplicationPlugin.h" 
     27#include "Visitor.h" 
     28 
     29using namespace std; 
     30using namespace boost; 
     31 
     32typedef split_iterator<string::iterator> sf_it; 
     33 
    734 
    835class MySoapServer : public Runnable 
    936{ 
    1037public: 
    11     MySoapServer(); 
     38    typedef boost::signal<void (DWORD, DWORD, wstring, wstring)> signal_visitEvent; 
     39    typedef pair <HMODULE, std::list<ApplicationPlugin*>*> PluginPair; 
     40    typedef pair <wstring, ApplicationPlugin*> ApplicationPair; 
     41    typedef pair <ApplicationPlugin*, Url*> VisitPair; 
     42public: 
     43    MySoapServer(Visitor *); 
    1244    ~MySoapServer(); 
    1345 
    1446    void run(); 
    1547 
     48    //Stolen from Visitor 
     49    void loadClientPlugins(); 
     50    ApplicationPlugin* createApplicationPluginObject(HMODULE hPlugin); 
     51    void onServerEvent(Element* pElement); 
     52 
    1653    Thread * MySoapServerThread; 
     54    signal_visitEvent signalVisitEvent; 
     55    stdext::hash_map<HMODULE, std::list<ApplicationPlugin*>*> applicationPlugins; 
     56    boost::signals::connection onServerVisitEventConnection; 
     57    stdext::hash_map<wstring, ApplicationPlugin*> applicationMap; 
     58 
     59    static void test(); 
     60    static Visitor * myVisitor; 
    1761 
    1862}; 
  • capture-mod/trunk/ProcessMonitor.h

    r823 r1644  
    5858    are attached to the onProcessEvent slot 
    5959 
    60     Implements: <IRunnable>, <VisitorListener>, <Monitor> 
     60    Implements: <Runnable>, <VisitorListener>, <Monitor> 
    6161*/ 
    6262class ProcessMonitor : public Runnable, public Monitor 
  • capture-mod/trunk/Thread.h

    r1585 r1644  
    2828    Class: Thread 
    2929 
    30     Class that accepts a pointer to another class that implements the <IRunnable> interface. This then wraps the c-style function  
     30    Class that accepts a pointer to another class that implements the <Runnable> interface. This then wraps the c-style function  
    3131    for creating a thread (threadProc) and creates an OO way to initialise, start, and stop a thread. 
    3232*/ 
     
    5555        Constructor: Thread 
    5656 
    57         Creates a thread object and stores the object which implements the IRunnable interface in <_threadObj> 
     57        Creates a thread object and stores the object which implements the Runnable interface in <_threadObj> 
    5858    */ 
    5959    Thread(Runnable *ptr) { 
     
    111111        Variable: _threadObj 
    112112 
    113         Pointer to an object which implements the IRunnable interface 
     113        Pointer to an object which implements the Runnable interface 
    114114    */ 
    115115    Runnable *_threadObj; 
  • capture-mod/trunk/Visitor.cpp

    r823 r1644  
    11#include "Visitor.h" 
    22 
     3unsigned int threadCount = 0; 
     4 
    35Visitor::Visitor(void) 
    46{ 
     
    68 
    79    hQueueNotEmpty = CreateEvent(NULL, FALSE, FALSE, NULL); 
     10    printf("Visitor: boost that sucka\n"); 
    811    onServerVisitEventConnection=EventController::getInstance()->connect_onServerEvent(L"visit", boost::bind(&Visitor::onServerEvent, this, _1)); 
    912 
    1013    loadClientPlugins(); 
    1114 
     15//  threadname = new char[10]; 
     16//  sprintf(threadname, "Visitor%d\n", threadCount); 
     17//  threadCount++; 
    1218    visitorThread = new Thread(this); 
    1319    visitorThread->start("Visitor"); 
     
    1925    CloseHandle(hQueueNotEmpty); 
    2026    unloadClientPlugins(); 
     27    delete threadname; 
    2128    // TODO free items in toVisit queue 
    2229} 
     
    3340    while(true) 
    3441    { 
     42        printf("Visitor::run, waiting\n"); 
    3543        WaitForSingleObject(hQueueNotEmpty, INFINITE); 
     44        printf("Visitor::run, runing\n"); 
    3645        VisitPair visit = toVisit.front(); 
    3746        toVisit.pop(); 
     
    8291        { 
    8392            wstring pluginDir = L"plugins\\"; 
    84             pluginDir += FindFileData.cFileName;            
     93            pluginDir += FindFileData.cFileName; 
    8594            HMODULE hPlugin = LoadLibrary(pluginDir.c_str()); 
    8695 
     
    174183Visitor::onServerEvent(Element* pElement) 
    175184{ 
     185    printf("Visitor::onServerEvent"); 
    176186    wstring applicationName = L"iexplore"; 
    177187    wstring url = L""; 
  • capture-mod/trunk/Visitor.h

    r823 r1644  
    6868 
    6969    boost::signals::connection onVisitEvent(const signal_visitEvent::slot_type& s); 
     70    void onServerEvent(Element* pElement); 
    7071private: 
    7172    void loadClientPlugins(); 
     
    7475    void run(); 
    7576 
    76     void onServerEvent(Element* pElement); 
     77//  void onServerEvent(Element* pElement); //XENO: Forced public for tests 
    7778 
    7879    ApplicationPlugin* createApplicationPluginObject(HMODULE hPlugin); 
     
    8687    boost::signals::connection onServerVisitEventConnection; 
    8788    stdext::hash_map<wstring, ApplicationPlugin*> applicationMap; 
     89 
     90    char * threadname; 
     91    ///int count; 
    8892}; 
  • capture-mod/trunk/soapC.cpp

    r1586 r1644  
    88#include "soapH.h" 
    99 
    10 SOAP_SOURCE_STAMP("@(#) soapC.cpp ver 2.7.10 2008-05-20 05:48:22 GMT") 
     10SOAP_SOURCE_STAMP("@(#) soapC.cpp ver 2.7.10 2008-06-27 05:00:35 GMT") 
    1111 
    1212 
  • capture-mod/trunk/soapClient.cpp

    r1586 r1644  
    77#include "soapH.h" 
    88 
    9 SOAP_SOURCE_STAMP("@(#) soapClient.cpp ver 2.7.10 2008-05-20 05:48:22 GMT") 
     9SOAP_SOURCE_STAMP("@(#) soapClient.cpp ver 2.7.10 2008-06-27 05:00:35 GMT") 
    1010 
    1111 
  • capture-mod/trunk/soapServer.cpp

    r1586 r1644  
    77#include "soapH.h" 
    88 
    9 SOAP_SOURCE_STAMP("@(#) soapServer.cpp ver 2.7.10 2008-05-20 05:48:22 GMT") 
     9SOAP_SOURCE_STAMP("@(#) soapServer.cpp ver 2.7.10 2008-06-27 05:00:35 GMT") 
    1010 
    1111