webengine/osswebengine/WebKitTools/Drosera/win/DebuggerApplication.cpp
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2  * Copyright (C) 2007 Apple, Inc.  All rights reserved.
       
     3  *
       
     4  * Redistribution and use in source and binary forms, with or without
       
     5  * modification, are permitted provided that the following conditions
       
     6  * are met:
       
     7  *
       
     8  * 1.  Redistributions of source code must retain the above copyright
       
     9  *     notice, this list of conditions and the following disclaimer. 
       
    10  * 2.  Redistributions in binary form must reproduce the above copyright
       
    11  *     notice, this list of conditions and the following disclaimer in the
       
    12  *     documentation and/or other materials provided with the distribution. 
       
    13  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
       
    14  *     its contributors may be used to endorse or promote products derived
       
    15  *     from this software without specific prior written permission. 
       
    16  *
       
    17  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
       
    18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
    19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
       
    20  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
       
    21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
       
    22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
       
    23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
       
    24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       
    25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
       
    26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    27  */
       
    28 
       
    29 #include "config.h"
       
    30 #include "DebuggerApplication.h"
       
    31 
       
    32 // ------------------------------------------------------------------------------------------------------------
       
    33 // FIXME This whole file needs to be re-written for win. However I'm leaving the functions here so I know
       
    34 // what still needs to be done.  Please ignore this code for now I have not looked at it closely.
       
    35 // ------------------------------------------------------------------------------------------------------------
       
    36 
       
    37 //#include <WebKit/WebCoreStatistics.h>
       
    38 //void DebuggerApplication::applicationDidFinishLaunching(NSNotification* ) // Get's called after main and the app has been created from the Nibs (called before applicationDidFinishLaunching)
       
    39 //{
       
    40 //    WebCoreStatistics.setShouldPrintExceptions(true);   //WebKit
       
    41 
       
    42     // Adding functions to be associated with notifications?
       
    43     // Need some way to get/handle notifications (JS?)
       
    44 //    [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(serverLoaded:) name:WebScriptDebugServerDidLoadNotification object:nil];
       
    45 //    [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(serverLoaded:) name:WebScriptDebugServerQueryReplyNotification object:nil];
       
    46 //    [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(serverUnloaded:) name:WebScriptDebugServerWillUnloadNotification object:nil];
       
    47 //    [[NSDistributedNotificationCenter defaultCenter] postNotificationName:WebScriptDebugServerQueryNotification object:nil];
       
    48 
       
    49 //#pragma mark -
       
    50 //#pragma mark Server Detection Callbacks
       
    51 
       
    52 void DebuggerApplication::serverLoaded()
       
    53 {
       
    54     // Get the process you are debugging
       
    55 //    int processId = [notification.userInfo(WebScriptDebugServerProcessIdentifierKey).(intValue);
       
    56     // make sure THIS is not the process
       
    57     //if (processId == [[NSProcessInfo processInfo] processIdentifier])
       
    58     //    return;
       
    59 
       
    60     //Get the server info from passed in notification?
       
    61     //check if info is in the server first
       
    62     m_knownServerNames->add(1, "Fake Server"); // setObject:info forKey:[notification object]];
       
    63 }
       
    64 
       
    65 void DebuggerApplication::serverUnloaded()
       
    66 {
       
    67     // remove passed in server
       
    68     m_knownServerNames->remove(1);
       
    69 }
       
    70 
       
    71 //#pragma mark -
       
    72 //#pragma mark Attach Panel Actions
       
    73 
       
    74 void DebuggerApplication::attach(int sender)   // actually attach Drosera to the WebKit app.
       
    75 {
       
    76     //Check that there are servers
       
    77 
       
    78     // get selected server
       
    79     unsigned int row = sender; //[[attachTable selectedRowIndexes] firstIndex];
       
    80     std::string key = m_knownServerNames->get(row);
       
    81 
       
    82 //    // DebuggerDocument will release on close
       
    83 //    DebuggerDocument *document = [[DebuggerDocument alloc] initWithServerName:key];
       
    84 //    [document showWindow:sender];
       
    85 }
       
    86 
       
    87 //#pragma mark -
       
    88 //#pragma mark Table View Delegate
       
    89 
       
    90 // How will delegates work in C++?
       
    91 //int numberOfRowsInTableView(NSTableView* tableView) // delegate. Returns number of rows in table. duh.
       
    92 int DebuggerApplication::numberOfRowsInTableView() const
       
    93 {
       
    94     return m_knownServerNames->size();
       
    95 }
       
    96 
       
    97 std::string DebuggerApplication::tableView()//(NSTableView* tableView, NSTableColumn* tableColumn, int row) // delegate. Called when table is displayed
       
    98 {
       
    99     return "";
       
   100 }
       
   101 
       
   102 void DebuggerApplication::tableView(/*(NSTableView* tableView, ID cell, NSTableColumn* tableColumn,*/ int row) // delegate. Called when table is displayed, displays the icon in the col/row ?
       
   103 {
       
   104     std::string key = m_knownServerNames->get(row);
       
   105 //    NSMutableDictionary *info = [m_knownServerNames objectForKey:key];
       
   106 //    string *processName = [info objectForKey:WebScriptDebugServerProcessNameKey];
       
   107 //    NSImage *icon = [info objectForKey:@"icon"];
       
   108 
       
   109 //    if (!icon) {
       
   110 //        NSString *path = [[NSWorkspace sharedWorkspace] fullPathForApplication:processName];
       
   111 //        if (path) icon = [[NSWorkspace sharedWorkspace] iconForFile:path];
       
   112 //        if (!icon) icon = [[NSWorkspace sharedWorkspace] iconForFileType:@"app"];
       
   113 //        if (icon) [info setObject:icon forKey:@"icon"];
       
   114 //        [icon setScalesWhenResized:YES];
       
   115 //        [icon setSize:NSMakeSize(32, 32)];
       
   116 //    }
       
   117 
       
   118 //    [cell setImage:icon];
       
   119 //    [cell setTitle:processName];
       
   120 }
       
   121