Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Merge branch 'issue/31' into develop
  • Loading branch information
pmuellr committed Mar 1, 2011
2 parents 86825c4 + 64e2886 commit da612d2f1cf8cf9f7f0dff716265971808b8bf0f
Show file tree
Hide file tree
Showing 21 changed files with 121 additions and 42 deletions.
@@ -5,6 +5,8 @@
* Copyright (c) 2010, 2011 IBM Corporation
*/

// messages from the client to the server

module weinre {
interface WeinreClientCommands {

@@ -15,6 +17,11 @@ module weinre {

void connectTarget(in string clientId, in string targetId);
void disconnectTarget(in string clientId);

void logDebug( in string message );
void logInfo( in string message );
void logWarning( in string message );
void logError( in string message );
};
}

@@ -5,6 +5,8 @@
* Copyright (c) 2010, 2011 IBM Corporation
*/

// messages from the server to the client

module weinre {
interface WeinreClientEvents {

@@ -5,13 +5,19 @@
* Copyright (c) 2010, 2011 IBM Corporation
*/

// messages from the target to the server

module weinre {
interface WeinreTargetCommands {

void registerTarget(int url, out string targetId);

void sendClientCallback(string callbackId, Object args);

void logDebug( in string message );
void logInfo( in string message );
void logWarning( in string message );
void logError( in string message );
};
}

@@ -5,6 +5,8 @@
* Copyright (c) 2010, 2011 IBM Corporation
*/

// messages from the server to the target

module weinre {
interface WeinreTargetEvents {

@@ -47,6 +47,7 @@ static public boolean isDebug() {
static public void warn( String message ) { Logger.warn(message); }
static public void info( String message ) { Logger.info(message); }
static public void debug( String message ) { Logger.debug(message); }
static public void error( String message ) { Logger.warn(message); }

//---------------------------------------------------------------
public Main(String[] args) {
@@ -75,4 +75,24 @@ public void disconnectTarget(Channel channel, String clientId, String callbackId
ConnectionManager.$.disconnect(client, target);
}

//---------------------------------------------------------------
public void logDebug(Channel channel, String message, String callbackId) {
Main.debug("client " + channel.getName() + ": " + message);
}

//---------------------------------------------------------------
public void logInfo(Channel channel, String message, String callbackId) {
Main.info("client " + channel.getName() + ": " + message);
}

//---------------------------------------------------------------
public void logWarning(Channel channel, String message, String callbackId) {
Main.warn("client " + channel.getName() + ": " + message);
}

//---------------------------------------------------------------
public void logError(Channel channel, String message, String callbackId) {
Main.error("client " + channel.getName() + ": " + message);
}

}
@@ -51,9 +51,30 @@ public void sendClientCallback(Channel channel, String clientCallbackId, Object
channel.sendCallback("WeinreClientEvents", clientCallbackId, argsArray);
}

//---------------------------------------------------------------
public void logDebug(Channel channel, String message, String callbackId) {
Main.debug("target " + channel.getName() + ": " + message);
}

//---------------------------------------------------------------
public void logInfo(Channel channel, String message, String callbackId) {
Main.info("target " + channel.getName() + ": " + message);
}

//---------------------------------------------------------------
public void logWarning(Channel channel, String message, String callbackId) {
Main.warn("target " + channel.getName() + ": " + message);
}

//---------------------------------------------------------------
public void logError(Channel channel, String message, String callbackId) {
Main.error("target " + channel.getName() + ": " + message);
}

//---------------------------------------------------------------
private String getCallbackConnectorId(String callbackId) {
int index = callbackId.indexOf("::");
return callbackId.substring(0, index);
}

}
@@ -21,7 +21,6 @@ requireClass ./RemotePanel

//-----------------------------------------------------------------------------
class Client
this.initialize()

//-----------------------------------------------------------------------------
init
@@ -128,3 +127,4 @@ method cb_webSocketClosed
//-----------------------------------------------------------------------------
static method main
Weinre.client = new Client()
Weinre.client.initialize()
@@ -40,7 +40,7 @@ method sendMessageToBackend(message)
if (object[0] == "setInjectedScriptSource") {
object[1] = "<long script elided>"
}
console.log(arguments.callee.signature + "(" + JSON.stringify(object,null,4) + ")")
Weinre.logInfo(arguments.callee.signature + "(" + JSON.stringify(object,null,4) + ")")

//-----------------------------------------------------------------------------
method _getPlatformAndPort
@@ -73,7 +73,7 @@ method connectionDestroyed(/*int*/ clientId, /*int*/ targetId)
if (!nextTargetId) return

Weinre.WeinreClientCommands.connectTarget(Weinre.clientId, nextTargetId)
console.log("autoconnecting to " + nextTargetId)
Weinre.logInfo("autoconnecting to " + nextTargetId)

//-----------------------------------------------------------------------------
method sendCallback(/*int*/ callbackId, /*any*/ result)
@@ -62,7 +62,7 @@ static method invoke(index, args)
catch (e) {
var funcName = func.name
if (!funcName) funcName = "<unnamed>"
console.log(arguments.callee.signature + " exception invoking callback: " + funcName + "(" + args.join(",") + "): " + e)
require("./Weinre").logError(arguments.callee.signature + " exception invoking callback: " + funcName + "(" + args.join(",") + "): " + e)
}
finally {
Callback.deregister(index)
@@ -7,6 +7,7 @@
*/

requireClass ./Ex
requireClass ./Weinre

//-----------------------------------------------------------------------------
class EventListeners
@@ -37,7 +38,7 @@ method fire(event)
listener.call(null, event)
}
catch(e) {
console.log(arguments.callee.signature + " invocation exception: " + e)
Weinre.logError(arguments.callee.signature + " invocation exception: " + e)
}
return
}
@@ -50,6 +51,6 @@ method fire(event)
listener.handleEvent.call(listener, event)
}
catch(e) {
console.log(arguments.callee.signature + " invocation exception: " + e)
Weinre.logError(arguments.callee.signature + " invocation exception: " + e)
}
})
@@ -84,7 +84,7 @@ static method validateAgainstIDL(klass, interfaceName)
if (!errors.length) return

errors.forEach(function(error){
console.log(error)
require("./Weinre").logError(error)
})

//-----------------------------------------------------------------------------
@@ -107,7 +107,7 @@ method _sendMethodInvocation(intfName, methodName, args)
this._socket.send(data)

if (Verbose) {
console.log(this.constructor.name + "[" + this._url + "]: send " + intfName + "." + methodName + "(" + JSON.stringify(args) + ")")
Weinre.logDebug(this.constructor.name + "[" + this._url + "]: send " + intfName + "." + methodName + "(" + JSON.stringify(args) + ")")
}

//-----------------------------------------------------------------------------
@@ -127,7 +127,7 @@ method _handleOpen
this._opened = true

if (Verbose) {
console.log(this.constructor.name + "[" + this._url + "]: opened")
Weinre.logDebug(this.constructor.name + "[" + this._url + "]: opened")
}

//-----------------------------------------------------------------------------
@@ -136,7 +136,7 @@ method _handleError(message)
this.close()

if (Verbose) {
console.log(this.constructor.name + "[" + this._url + "]: error: " + message)
Weinre.logDebug(this.constructor.name + "[" + this._url + "]: error: " + message)
}

//-----------------------------------------------------------------------------
@@ -163,7 +163,7 @@ method _handleMessage(message)
}

if (!intf) {
console.log("weinre: request for non-registered interface:" + methodSignature)
Weinre.logWarning("weinre: request for non-registered interface:" + methodSignature)
return
}

@@ -179,17 +179,17 @@ method _handleMessage(message)
method.apply(intf, args)
}
catch (e) {
console.log("weinre: invocation exception on " + methodSignature + ": " + e)
Weinre.logError("weinre: invocation exception on " + methodSignature + ": " + e)
}

if (Verbose) {
console.log(this.constructor.name + "[" + this._url + "]: recv " + intfName + "." + methodName + "(" + JSON.stringify(args) + ")")
Weinre.logDebug(this.constructor.name + "[" + this._url + "]: recv " + intfName + "." + methodName + "(" + JSON.stringify(args) + ")")
}

//-----------------------------------------------------------------------------
method _handleClose
this._reallyClosed = true

if (Verbose) {
console.log(this.constructor.name + "[" + this._url + "]: closed")
Weinre.logDebug(this.constructor.name + "[" + this._url + "]: closed")
}
@@ -183,7 +183,7 @@ method _handleXhrResponseError(xhr)
message: "error from XHR invocation: " + xhr.statusText
})

console.log("error from XHR invocation: " + xhr.status + ": " + xhr.statusText)
Weinre.logError("error from XHR invocation: " + xhr.status + ": " + xhr.statusText)

//-----------------------------------------------------------------------------
method _xhr(url, method, data, handler)
@@ -19,6 +19,7 @@ init
var _notImplemented = {}
var _showNotImplemented = false
var CSSProperties = []
var logger = null

//-----------------------------------------------------------------------------
static method addIDLs(idls)
@@ -43,11 +44,37 @@ static method notImplemented(thing)
_notImplemented[thing] = true

if (!_showNotImplemented) return
console.log("weinre: " + thing + " not implemented")
Weinre.logWarning(thing + " not implemented")

//-----------------------------------------------------------------------------
static method showNotImplemented()
_showNotImplemented = true
for (var key in _notImplemented) {
console.log("weinre: " + key + " not implemented")
}
Weinre.logWarning(key + " not implemented")
}

//-----------------------------------------------------------------------------
static method logError(message)
getLogger().logError(message)

//-----------------------------------------------------------------------------
static method logWarning(message)
getLogger().logWarning(message)

//-----------------------------------------------------------------------------
static method logInfo(message)
getLogger().logInfo(message)

//-----------------------------------------------------------------------------
static method logDebug(message)
getLogger().logDebug(message)

//-----------------------------------------------------------------------------
function getLogger()
if (logger) return logger

if (Weinre.client) logger = Weinre.WeinreClientCommands
else if (Weinre.target) logger = Weinre.WeinreTargetCommands

return logger

@@ -31,11 +31,11 @@ requireClass ./WiRuntimeImpl

//-----------------------------------------------------------------------------
class Target
this.initialize()

//-----------------------------------------------------------------------------
static method main
Weinre.target = new Target()
Weinre.target.initialize()

Weinre.addCSSProperties = function addCSSProperties(properties) {
CSSStore.addCSSProperties(properties)
@@ -127,7 +127,7 @@ static method handleError(event)
var lineno = event.lineno || "[unknown lineno]"
var message = event.message || "[unknown message]"

console.error("error occurred: " + filename + ":" + lineno + ": " + message)
Weinre.logError("error occurred: " + filename + ":" + lineno + ": " + message)

//-----------------------------------------------------------------------------
method cb_webSocketOpened()
@@ -18,13 +18,9 @@ class WeinreTargetEventsImpl
method connectionCreated(/*string*/ clientId, /*string*/ targetId)
var message = "weinre: target " + targetId + " connected to client " + clientId

console.log(message)
Weinre.logInfo(message)
var oldValue = Console.useRemote(true)

if (!oldValue) {
console.log(message)
}

// Weinre.showNotImplemented()

Weinre.target.setDocument()
@@ -34,13 +30,9 @@ method connectionCreated(/*string*/ clientId, /*string*/ targetId)
method connectionDestroyed(/*string*/ clientId, /*string*/ targetId)
var message = "weinre: target " + targetId + " disconnected from client " + clientId

console.log(message)
Weinre.logInfo(message)
var oldValue = Console.useRemote(false)

if (oldValue) {
console.log(message)
}

//-----------------------------------------------------------------------------
method sendCallback(/*int*/ callbackId, /*any*/ result)
Callback.invoke(callbackId, result)
@@ -17,7 +17,7 @@ method getStylesForNode(/*int*/ nodeId, callback)

var node = Weinre.nodeStore.getNode(nodeId)
if (!node) {
console.log(arguments.callee.signature + " passed an invalid nodeId: " + nodeId)
Weinre.logWarning(arguments.callee.signature + " passed an invalid nodeId: " + nodeId)
return
}

@@ -50,7 +50,7 @@ method getStylesForNode(/*int*/ nodeId, callback)
method getComputedStyleForNode(/*int*/ nodeId, callback)
var node = Weinre.nodeStore.getNode(nodeId)
if (!node) {
console.log(arguments.callee.signature + " passed an invalid nodeId: " + nodeId)
Weinre.logWarning(arguments.callee.signature + " passed an invalid nodeId: " + nodeId)
return
}

@@ -65,7 +65,7 @@ method getComputedStyleForNode(/*int*/ nodeId, callback)
method getInlineStyleForNode(/*int*/ nodeId, callback)
var node = Weinre.nodeStore.getNode(nodeId)
if (!node) {
console.log(arguments.callee.signature + " passed an invalid nodeId: " + nodeId)
Weinre.logWarning(arguments.callee.signature + " passed an invalid nodeId: " + nodeId)
return
}

0 comments on commit da612d2

Please sign in to comment.