Hello everyone. Does anyone of you use xmlrpc in FF1.5 ? i have piece of
code that using xml-rpc and it is works fine on firefox 1.0.7 but when i
moved to firefox 1.5 the problem starts. It looks like stream is not
completly on all I see is the exception:
c, the code work fine on firefox1.0.7 but when i used on FF1.5Beta2 it
generate error: 0x80470002 (NS_BASE_STREAM_CLOSED)
[nsIScriptableInputStream.available]
Here is the piece of my code:
The function send the data to server is called: wyslij
var XmlRpcListener2 = {
setStatus: function(msgbd) {
var sBarDisp = document.getElementById("statusbar-display");
var tooltip = document.getElementById('profile-tooltip-value');
if (sBarDisp) sBarDisp.label = msgbd;
if (tooltip) tooltip.setAttribute("value", msgbd);
},
setStatus2: function(msgst) {
var sBarStat = document.getElementById('profile-status');
var tooltip = document.getElementById('profile-tooltip-value');
sBarStat.setAttribute("status", msgst);
tooltip.setAttribute("value", msgst);
},
onResult: function(client, ctxt, result) {
MyXmlUtil.xmlRpcProgress = false;
Konsola('on result');
window.clearTimeout(ffprof2util.rpcToutId);
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect
UniversalBrowserAccess');
try {
result = result.QueryInterface(Components.interfaces.nsISupportsPRInt32);
} catch (e) {
Konsola('on result, siegam po komponent');
this.setStatus("ex in onResult:" + e.message);
}
Konsola('rezultat - odpowiedz' + result +' '+ result.data);
//this.setStatus("Sending page:" + result.toString(16));
this.setStatus2(result);
switch (result.data) {
case 0x00:
Konsola("Strona istnieje w Twoim Profile(tm)");
this.setStatus("Strona istnieje w Twoim Profile(tm)");
break;
case 0x04:
case 0x01:
Konsola("Brak Strony w Twoim Profile(tm)");
this.setStatus("Brak Strony w Twoim Profile(tm)");
break;
default:
Konsola("blad - w result data" +result.data );
this.setStatus("BLAD!: " + result.data);
break;
}
if (lastRpcCall == "bookUpload" && toGridGFlag && result.data==0 ) {
//FFProf_LoadAdd2GridPage();
}
},
onFault: function(client, ctxt, fault) {
MyXmlUtil.xmlRpcProgress = false;
window.clearTimeout(ffprof2util.rpcToutId);
Konsola('Fault! ' + fault);
this.setStatus('Fault! ' + fault);
this.setStatus2(2);
},
onError: function(client, ctxt, status, errorMsg) {
MyXmlUtil.xmlRpcProgress = false;
window.clearTimeout(MyXmlUtil.rpcToutId);
Konsola('funkcja onError');
Konsola('ctx' + ctxt + ' status ' + status);
this.setStatus2(2);
switch (status) {
case 0x80470002:
Konsola('funkcja onError case 0x80470002: nie wiem co to znaczy?');
case 0x80004005:
Konsola('case 0x80004005' + errorMsg);
this.setStatus(status.toString(16) + ":" + errorMsg);
break;
default:
Konsola('onError default ' + errorMsg);
this.setStatus('Error!!! (' + status.toString(16) + ') ' + errorMsg);
//alert('Error!!! (' + status.toString(16) + ') ' + errorMsg + '\n');
break;
}
}
};
//glowna funkcja startujaca
var MyXmlUtil = {
//tu sa glowne zmienne ale nie tylko
nsIXmlRpcSrv : null,
xmlMethod : null,
xmlRpcClient : null,
xmlRpcProgress :null,
result : null,
nsIIOService : null,
xmlRpcArgs : null,
xmlRpcArg0 : null,
xmlRpcArg1 : null,
xmlRpcArg2 : null,
rpcToutId : null,
getClient : function () {
netscape.security.PrivilegeManager.enablePrivilege(
'UniversalXPConnect UniversalBrowserAccess');
return Components.classes['@mozilla.org/xml-rpc/client;1'].createInstance(
Components.interfaces.nsIXmlRpcClient);
},
getXmlRpc : function() {
if (!this.xmlRpcClient) this.xmlRpcClient = this.getClient();
return this.xmlRpcClient;
},
init: function()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
if(! this.nsIIOService)
this.nsIIOService= Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
this.xmlRpcArgs = [null, null, null, null, null, null, null];
this.result = [0,0,0,1];
if(!this.baseURL ) this.setBaseURL();
this.initXmlRpc();
},
initXmlRpc:function () {
try {
//zmienna zawierajaca glowna instancje obiektu
this.nsIXmlRpcSrv = this.getXmlRpc();
this.nsIXmlRpcSrv.init( "http://localhost:8080/RemoteSrv");
Konsola('ustawiamy url metody serwera');
} catch (e) {
Konsola('jest wyjatek 1 w initXmlRpc');
alert (e.message);
}
this.xmlRpcProgress = false;
this.xmlMethod = "bookUpload";
for (i = 0; i< 6; i++) {
this.xmlRpcArgs[i] = this.nsIXmlRpcSrv.createType(this.nsIXmlRpcSrv.STRING,
{});
}
this.xmlRpcArgs[6] = this.nsIXmlRpcSrv.createType(this.nsIXmlRpcSrv.BOOLEAN,
{});
try {
this.xmlRpcArg0 = this.nsIXmlRpcSrv.createType(this.nsIXmlRpcSrv.STRING,
{});
this.xmlRpcArg1 = this.nsIXmlRpcSrv.createType(this.nsIXmlRpcSrv.STRING,
{});
} catch (e) {
Konsola('tworzymy argumenty');
Konsola('jest wyjatek 2 w initXmlRpc');
alert (e.message);
}
xmlRpcStarted = true;
},
wyslij : function (iUrl, iDescr, iKeyw, vListen, a2Grid) {
// ffprof2util.sendOneBookmark(oUrl, oDescr, oKeyw, XmlRpcListener2,
toGridGFlag);
Konsola("Metoda sendOneBookmark a raczej jej odpowiednik");
this.xmlRpcArgs[0].data = ffpCfgLogin;
this.xmlRpcArgs[1].data = ffpCfgPasswd;
this.xmlRpcArgs[2].data = iUrl;
this.xmlRpcArgs[3].data = escape(window._content.document.title); //title
this.xmlRpcArgs[4].data = escape(iKeyw);
this.xmlRpcArgs[5].data = escape(iDescr);
this.xmlRpcArgs[6].data = a2Grid;
var xmlTimeout = 0;
/*try {
xmlTimeout = nsPreferences.getIntPref ("ffprofile.rpctimeout");
}
catch (e) {
xmlTimeout = profDefRpcTimeout;
}*/
if (xmlTimeout == null) xmlTimeout = profDefRpcTimeout;
try {
lastRpcCall = this.xmlMethod;
//Components.reportError("proba przed asyncCall")
Konsola('Wysylamy dane do metody ' + this.xmlMethod);
Konsola(this.xmlRpcArgs[0]+ ' ' + this.xmlRpcArgs[1] +' ' +
this.xmlRpcArgs[2] +' ' + this.xmlRpcArgs[3] + ' ' +this.xmlRpcArgs[4] +' '
+ this.xmlRpcArgs[5] + ' ' +this.xmlRpcArgs[6] );
this.nsIXmlRpcSrv.asyncCall(vListen, null, this.xmlMethod,
[this.xmlRpcArgs[0], this.xmlRpcArgs[1], this.xmlRpcArgs[2],
this.xmlRpcArgs[3], this.xmlRpcArgs[4], this.xmlRpcArgs[5],
this.xmlRpcArgs[6] ], 7);
//Components.reportError("proba po asyncCall")
Konsola('Poszlo');
retry = false;
this.xmlRpcProgress = true;
//this.rpcToutId = window.setTimeout(this.xmlRpcAbort, xmlTimeout);
}
catch (e) {
Konsola('wyjatek w asynCall');
this.setStatus('Error!!! (' + e.message + ') ');
}
},
setBaseURL: function()
{
var url=null;
var nsIDirectoryService =
Components.classes['@mozilla.org/file/directory_service;1']
.getService(Components.interfaces.nsIProperties);
if(! this.nsIIOService)
this.nsIIOService= Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var targetFile = nsIDirectoryService.get('ProfD',
Components.interfaces.nsIFile);
targetFile.append("chrome");
targetFile.append("ProfileResource");
if( targetFile.exists() && targetFile.isDirectory() )
{
url = this.nsIIOService.newFileURI(targetFile).spec;
alert(url);
if( url && url.charAt(url.length - 1) != "/") url = url +"/";
}
if(url) this.baseURL=url;
else this.baseURL = "chrome://ffprofilex1/skin/icons/";
},
odpal:function () {
if (xmlRpcStarted == false) this.init();
wyslij.sendOneBookmark(oUrl, oDescr, oKeyw, XmlRpcListener2, toGridGFlag);
}
}
|