PK 66 F"content/flock/common/aboutWD.xhtml About: Web Detective PK vA$77^jbb)content/flock/common/accountManagement.js// BEGIN FLOCK GPL // // Copyright Flock Inc. 2005-2007 // http://flock.com // // This file may be used under the terms of of the // GNU General Public License Version 2 or later (the "GPL"), // http://www.gnu.org/licenses/gpl.html // // Software distributed under the License is distributed on an "AS IS" basis, // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License // for the specific language governing rights and limitations under the // License. // // END FLOCK GPL Cc = Components.classes; Ci = Components.interfaces; var gService = null; /* * Coop stuff */ var faves_coop = Cc["@flock.com/singleton;1"] .getService(Ci.flockISingleton) .getSingleton("chrome://flock/content/common/load-faves-coop.js") .wrappedJSObject; function onLoad() { // Populates the service list serviceList = $("serviceList"); // Do we need to select a given service first? var params = window.arguments[0]; // Load the accounts for the first service var services = getFlockWebServices() for (var i = 0; i < services.length; i++) { var contractID = services[i][0]; var svc = services[i][1]; var accountitem = document.createElement("listitem"); accountitem.setAttribute('label', svc.title); accountitem.setAttribute('value', contractID); accountitem.setAttribute('image', svc.icon); accountitem.setAttribute('class', 'listitem-iconic'); // accountitem.setAttribute('onclick', 'loadService("'+contractID+'")'); accountitem.svc = svc; serviceList.appendChild(accountitem); } if (params && params.serviceid) loadService(params.serviceid); updateButtons(); } function getServiceConfirmation(aUrn) { var prefs = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefService) .getBranch("flock.service.confirmation."); var value = null; try{ value = prefs.getBoolPref (aUrn); } catch(e) { return true; // default value is to ask the user } return value; } function setServiceConfirmation(aUrn, aValue) { var prefs = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefService) .getBranch("flock.service.confirmation."); prefs.setBoolPref (aUrn, aValue); } function loadService(aContractID) { gService = Cc[aContractID].getService(Ci.flockIWebService); var accountList = $('accountList'); $("accounts-label").value = "Accounts on "+gService.title+":"; // Clean the account list while (accountList.getRowCount() > 0) { accountList.removeItemAt(0); } // Populate the account list var enum = faves_coop.accounts_root.children.enumerate(); while (enum.hasMoreElements()) { var account = enum.getNext(); if (!account) continue; // getNext() can return NULL when hasMoreElements() is TRUE. if (account.serviceId == aContractID) { var accountitem = document.createElement("listitem"); var label = account.name; if (account.service.logoutOption) { if (account.isAuthenticated) { label += " - logged in"; } else { label += " - logged out"; } } else { label += " - configured"; } accountitem.setAttribute('label', label); accountitem.setAttribute('value', account.id()); accountitem.setAttribute('style', 'font-style: italic;'); accountList.appendChild(accountitem); } } // Select the first account or show the login instructions if (accountList.getRowCount() > 0) { $('accountDeck').selectedIndex = 0; accountList.selectedIndex = 0; } else { $('accountDeck').selectedIndex = 1; $('login-link').setAttribute('onclick', 'openUILinkIn("'+gService.url+'", "window");window.close();'); $('login-link').textContent = gService.url; } // update the loginDetect button var loginDetect = getServiceConfirmation(gService.urn); $('dont-logindetect').setAttribute('checked', !loginDetect); } function updateService() { var cid = $('serviceList').selectedItem.value; loadService(cid); updateButtons(); } function updateButtons() { var noselection = ($('accountList').selectedItem == null); $('logout-button').setAttribute('disabled', noselection); $('forget-button').setAttribute('disabled', noselection); if (!noselection) { var id = $('accountList').selectedItem.value; var account = faves_coop.get(id); $('logout-button').setAttribute('disabled', !account.service.logoutOption); try { // Account selected AND service implements flockISocialWebService gService.QueryInterface(Ci.flockISocialWebService); $('showInSidebar-check').setAttribute('disabled', 'false'); $('showInSidebar-check').setAttribute('checked', account.showInSidebar); } catch(e) { // Account selected, but service doesn't implement flockISocialWebService $('showInSidebar-check').setAttribute('disabled', 'true'); $('showInSidebar-check').setAttribute('checked', 'false'); } } else { // No account selected $('showInSidebar-check').setAttribute('disabled', true); $('showInSidebar-check').setAttribute('checked', false); } } function forgetAccount() { var svc = $('serviceList').selectedItem.svc; var cid = $('serviceList').selectedItem.value; var id = $('accountList').selectedItem.value; var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService); if (prompts.confirm(window, "Forget Account", "This action will remove this account completely! Are you sure this is what you want to do?")) { svc.getAccount(id).logout(null); svc.removeAccount(id); loadService(cid); } } function logoutAccount() { var svc = $('serviceList').selectedItem.svc; var cid = $('serviceList').selectedItem.value; var id = $('accountList').selectedItem.value; var acct = svc.getAccount(id); acct.logout(null); loadService(cid); } function toggleShowInSidebar(aChecked) { var id = $('accountList').selectedItem.value; var account = faves_coop.get(id); account.showInSidebar = aChecked; } function toggleLoginDetection(aChecked) { var svc = $('serviceList').selectedItem.svc; setServiceConfirmation(svc.urn, !aChecked); } var getFlockWebServices = function() { var CATMAN = Cc['@mozilla.org/categorymanager;1'].getService(Ci.nsICategoryManager); var webServices = new Array(); var e = CATMAN.enumerateCategory('flockWebService'); while (e.hasMoreElements()) { try { var entry = e.getNext().QueryInterface(Ci.nsISupportsCString); if (!entry) { continue; } var contractID = CATMAN.getCategoryEntry('flockWebService', entry.data); var svc = Cc[contractID].getService(Ci.flockIWebService); webServices.push([contractID, svc]); } catch (e) { dump(e); } } dump('Found '+webServices.length+' flock web services'); return webServices; } PK '$7sy y *content/flock/common/accountManagement.xul %flockAccountDTD; ]> PK M7KK#content/flock/menus/setsOverlay.xul %menusDTD; %favoritesDTD; ]> PK d)7zV$content/flock/xmlrpc/xmlrpchelper.js// vim: ts=4 sw=4 expandtab cindent foldmethod=marker filetype=javascript // // BEGIN FLOCK GPL // // Copyright Flock Inc. 2005-2007 // http://flock.com // // This file may be used under the terms of of the // GNU General Public License Version 2 or later (the "GPL"), // http://www.gnu.org/licenses/gpl.html // // Software distributed under the License is distributed on an "AS IS" basis, // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License // for the specific language governing rights and limitations under the // License. // // END FLOCK GPL Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); const flockIXmlRpcValue = Components.interfaces.flockIXmlRpcValue; const flockIXmlRpcServer = Components.interfaces.flockIXmlRpcServer; /* Keep this object in sync between: $c/xmlrpc/src/flockXmlRpcServer.js and: $c/xmlrpc/public/xmlrpchelper.js */ function XmlRpcValue(aType) { this.XmlRpcType = aType; } XmlRpcValue.prototype.QueryInterface = new XPCOMUtils.generateQI([flockIXmlRpcValue]); XmlRpcValue.Int = function XRV_Int(aValue) { var value = new XmlRpcValue(flockIXmlRpcValue.TYPE_INT); value.IntValue = aValue; return value; } XmlRpcValue.Boolean = function XRV_Boolean(aValue) { var value = new XmlRpcValue(flockIXmlRpcValue.TYPE_BOOLEAN); value.BooleanValue = aValue; return value; } XmlRpcValue.String = function XRV_String(aValue) { var value = new XmlRpcValue(flockIXmlRpcValue.TYPE_STRING); value.StringValue = aValue; return value; } XmlRpcValue.Double = function XRV_Double(aValue) { var value = new XmlRpcValue(flockIXmlRpcValue.TYPE_DOUBLE); value.DoubleValue = aValue; return value; } XmlRpcValue.DateTime = function XRV_DateTime(aValue) { var value = new XmlRpcValue(flockIXmlRpcValue.TYPE_DATETIME); value.DateTimeValue = aValue.getTime() / 1000; return value; } XmlRpcValue.Array = function XRV_Array(aValue) { var value = new XmlRpcValue(flockIXmlRpcValue.TYPE_ARRAY); value._value = aValue; value.ArrayElements = function XRV_Array_ArrayElements(aCount) { aCount.value = this._value.length; return this._value; }; return value; } XmlRpcValue.Struct = function XRV_Struct(aValue) { var value = new XmlRpcValue(flockIXmlRpcValue.TYPE_STRUCT); value._value = aValue; value.StructKeys = function XRV_Struct_StructKeys(aCount) { var keys = []; for (var x in this._value) { keys.push (x); } aCount.value = keys.length; return keys; }; value.StructItem = function XRV_Struct_StructItem(aKey) { if (this._value[aKey]) { return this._value[aKey]; } else { return null; } }; return value; } XmlRpcValue.Base64 = function XRV_Base64(aValue) { var value = new XmlRpcValue(flockIXmlRpcValue.TYPE_BASE64); value.Base64Value = aValue; return value; } XmlRpcValue.FromJavaScript = function XRV_FromJavaScript(value) { if (value == null || value == undefined) { return null; } switch (value.constructor) { case Number: if (Math.floor(value) != value) { return this.Double(value); } else { return this.Int(value); } case Boolean: return this.Boolean(value); case String: return this.String(value); case Date: return this.DateTime(value); case Array: var arr = []; for (var i in value) { var v = this.FromJavaScript(value[i]); if (v != null && v != undefined) { arr.push (v); } } return this.Array(arr); case Object: var obj = new Object (); for (var k in value) { var v = this.FromJavaScript(value[k]); if (v != null && v != undefined) { obj[k] = v; } } return this.Struct(obj); case XmlRpcValue: // its already the right type return value; case Function: // ignore methods return null; default: throw "error in XmlRpcValue.FromJavaScript converting " + value + " " + "(type " + value.constructor + ")"; } } XmlRpcValue.ToJavaScript = function XRV_ToJavaScript(value) { if (value == undefined) { return null; } // FIXME: why the next two blocks? if (value.QueryInterface) { value = value.QueryInterface(flockIXmlRpcValue); if (value == null) { return null; } } else { return null; } try { value = value.QueryInterface(flockIXmlRpcValue); } catch (ex) { return value; } switch (value.XmlRpcType) { case flockIXmlRpcValue.TYPE_INT: return value.IntValue; case flockIXmlRpcValue.TYPE_BOOLEAN: return value.BooleanValue; case flockIXmlRpcValue.TYPE_STRING: return value.StringValue; case flockIXmlRpcValue.TYPE_DOUBLE: return value.DoubleValue; case flockIXmlRpcValue.TYPE_DATETIME: var date = new Date(); date.setTime(value.DateTimeValue * 1000); return date; case flockIXmlRpcValue.TYPE_ARRAY: var arr = []; var elements = value.ArrayElements({}); for (var i in elements) { arr.push(XmlRpcValue.ToJavaScript(elements[i])); } return arr; case flockIXmlRpcValue.TYPE_STRUCT: var keys = value.StructKeys({}); var struct = {}; for (var i in keys) { var key = keys[i]; var xmlval = value.StructItem(key); var val = XmlRpcValue.ToJavaScript(xmlval); struct[key] = val; } return struct; case flockIXmlRpcValue.TYPE_BASE64: return value.Base64Value; default: throw "error in XmlRpcValue.ToJavaScript"; } } function flockXmlRpcServer(aURL) { this._server = Components.classes['@flock.com/xmlrpc/server;1'] .createInstance(flockIXmlRpcServer); this._server.init(aURL); } flockXmlRpcServer.prototype.call = function XRS_call(aMethod, aArguments, aListener) { var args = XmlRpcValue.FromJavaScript(aArguments); var listener = { onResult: function XRS_call_onResult(aResult) { aListener.onResult(XmlRpcValue.ToJavaScript(aResult)); }, onFault: function XRS_call_onFault(aFaultCode, aFaultString) { aListener.onFault(aFaultCode, aFaultString); }, onError: function XRS_call_onError(aMessage) { aListener.onError(aMessage); } }; this._server.call(aMethod, args, listener); } flockXmlRpcServer.prototype.makeProxy = function XRS_makeProxy(aMethods) { var proxy = { __server: this }; for each (var method_name in aMethods) { var property = method_name.replace(/\./g, '_'); proxy[property] = function XRS_makeProxy_property() { if (arguments.length < 1) { throw "not enough arguments"; } proxy.__server.call(method_name, arguments.slice(0, arguments.length - 1), arguments[arguments.length - 1]); } } return proxy; } PK B7wM]++&content/flock/bindings/accountInfo.xml PK '7+NvJJ/content/flock/services/flickr/flickrOverlay.xul PK L+7oA"")content/flock/services/flickr/favicon.pngPNG  IHDRh6IDAT(c?)$tN[Fp3aKe^' +1g`ba```݆[TH0000gh=\kdx'kdR+lF !LKtދ[J1"LX{0Y*J# xIi03T[aWg$o򁑁]G@h-gTfUc+i~ I5]4UFM _IENDB`PK 26گh??.content/flock/services/photobucket/favicon.pngPNG  IHDRh6gAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb?) H/L|lYd\uŞ/no+b,T 1?}tK*)  1/Y* 1=tf@#0*wR'lve8t$q/'SXOtuej 3qlcnY%9=𓊔g ?~37H?~aPW`f̙}QVVh.@~1*W:f- `L)2/EoL"/3  oVJ\yX.a14# n>@2.jYpl 32|;P?0 wƿ19$ A6 1SqϹQX4ݸ V<#|W/ nj$cRlt?a(_U쌌 w2~aag~Jq33 BFVP FR7@"7ѝIENDB`PK a7 0(content/flock/services/piczo/favicon.pngPNG  IHDR(-SgAMAOX2tEXtSoftwareAdobe ImageReadyqe<PLTE㱰sppSRQѼ+)*ۘؑ똹׈ 텄ڐ񌋌b^\⢝枚D@=ꏳشIIDATxT@ ,*R]lXK&g%yyibЗ^boZ(z[vfsz6V&?ֳ*с0vU GhY@eZD7k *AWf"9ʏk`B0w@E\"K98:&WE0t(59;IENDB`PK 27N&*content/flock/services/twitter/favicon.pngPNG  IHDRh6 pHYs  oIDAT(MnA= 9RqnekNÚ]YX!!AıSEfM)Uu6`X-%V*:*e=iqQ/LS,+X@ r`$e]D1aN@^DZp# RU;D+N9$,i,UJ8ݵdnF:kv];C-&k{fHYaD{6wx0Pm9VN*xT r7'GgaXw>lH+Ÿ$ؽ @w7NG+vm7vc~TueEsA8z:YCu'4ذ͑IENDB`PK 27uu,content/flock/services/twitter/faviconBW.pngPNG  IHDRh6 pHYs  'IDAT(u0 Dm'@PD=?JU4Ms!B<+̌+[>W?_C7DiۮkC>1"~ۆD$c\kvs&"x<8Mv "M*@ĔRJie( nzs |<j; "bVsswt'qb]D2|~/M*@a0\.ita`fU1BX1 PK '7 ??1content/flock/services/youtube/youtubeOverlay.xul PK 260b.content/flock/services/searchvideo/favicon.pngPNG  IHDRaIDAT81 E㎣Kx *lmv/a+XYrta8+f{!<̾/P9@w@D@ļ%gԥn,Yဉ()%DXۂ-( s9dwZO](90/p%] 695hx#O¡$AT{o-n{؎IENDB`PK 3#7T%%content/flock/blog/atom.js// BEGIN FLOCK GPL // // Copyright Flock Inc. 2005-2007 // http://flock.com // // This file may be used under the terms of of the // GNU General Public License Version 2 or later (the "GPL"), // http://www.gnu.org/licenses/gpl.html // // Software distributed under the License is distributed on an "AS IS" basis, // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License // for the specific language governing rights and limitations under the // License. // // END FLOCK GPL // Sample AtomEntry: // entry = { // id: "urn:example.org:reilly:1", // link: "http://example.org/reilly/2003/02/05#My_First_Entry" // title: "My First Entry", // summary: "A very boring entry...", // categories: ["one", "two"], // author_name: "Bob B. Bobbington", // author_url: "http://bob.name/", // issued: new Date(), // created: new Date(), // modified: new Date(), // content: "

The complete entry....
blablabla...

", // } // // /!\ Some attributes are optionals, some are required according to the call that is done. const FLOCK_GENERATOR = "Flock Alpha"; var flockAtomPost = function(listener, aPostURI, aAtomEntry, auth) { // Make sure we have the required fields if (!aAtomEntry.title) aAtomEntry.title = ""; if (!aAtomEntry.issued) aAtomEntry.issued = ""; // An empty 'issued' means now (in the timezone of the server) var entry = ; entry.@xmlns = 'http://www.w3.org/2005/Atom'; entry.generator = FLOCK_GENERATOR; entry.generator.@url = 'http://flock.com'; entry.title = aAtomEntry.title; entry.title.@mode = 'escaped'; if (aAtomEntry.summary) entry.summary = aAtomEntry.summary; if (aAtomEntry.content) { entry.content = aAtomEntry.content; entry.content.@mode = 'escaped'; } if (aAtomEntry.created) entry.created = aAtomEntry.created; if (aAtomEntry.author_name) { entry.author.name = aAtomEntry.author_name; if (aAtomEntry.author_url) entry.author.url = aAtomEntry.author_url; } if (aAtomEntry.categories) { for (i in aAtomEntry.categories) { entry.category[i] = ""; entry.category[i].@term = aAtomEntry.categories[i]; entry.category[i].@scheme = "http://www.blogger.com/atom/ns#"; } } flockAtomDoRequest(listener, aPostURI, 'POST', entry, auth); } var flockAtomEdit = function(listener, aEditURI, aAtomEntry, auth) { var entry = ; entry.@xmlns = 'http://www.w3.org/2005/Atom'; entry.generator = FLOCK_GENERATOR; entry.generator.@url = 'http://flock.com'; entry.id = aAtomEntry.id; entry.title = aAtomEntry.title; entry.title.@mode = 'escaped'; entry.issued = aAtomEntry.issued; if (aAtomEntry.summary) entry.summary = aAtomEntry.summary; if (aAtomEntry.content) { entry.content = aAtomEntry.content; entry.content.@mode = 'escaped'; } if (aAtomEntry.created) entry.created = aAtomEntry.created; if (aAtomEntry.author_name) { entry.author.name = aAtomEntry.author_name; if (aAtomEntry.author_url) entry.author.url = aAtomEntry.author_url; } if (aAtomEntry.categories) { for (i in aAtomEntry.categories) { entry.category[i] = ""; entry.category[i].@term = aAtomEntry.categories[i]; entry.category[i].@scheme = "http://www.blogger.com/atom/ns#"; } } flockAtomDoRequest(listener, aEditURI, 'PUT', entry, auth); } var flockAtomDelete = function(listener, aEditURI, auth) { flockAtomDoRequest(listener, aEditURI, 'DELETE', null, auth); } // Private methods var flockAtomParseEntry = function(aEntryDom) { // Only get the information we really care about var entry = new Object(); var entryTag = aEntryDom.getElementsByTagName("entry")[0]; entry.id = entryTag.getElementsByTagName("id")[0].nodeValue; var linkTags = entryTag.getElementsByTagName("link"); for (i = 0; i < linkTags.length; i++) { var link = linkTags[i]; if (link.getAttribute("rel").match(/edit/)) { entry.link = link.getAttribute('href'); } else if (link.getAttribute("rel").match(/alternate/)) { entry.editURI = link.getAttribute('href'); } } return entry; } var flockAtomParsePosts = function(listener, inst) { var dom = inst._req.responseXML; debug("Status: "+inst._req.status); debug(inst._req.responseText); switch (inst._req.status) { case 200: // No server should ever return a 200 after a POST or a PUT, // but they do it anyway if (!dom) { // Livejournal hackage: they return an HTML page instead of an Atom Entry if(inst._req.responseText.match(/OK/)) { listener.onResult(new Object()); return; } else { var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"].getService(Components.interfaces.nsILocaleService); var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].getService(Components.interfaces.nsIStringBundleService); var stringBundle = stringBundleService.createBundle("chrome://flock/locale/blog/blog.properties", localeService.getApplicationLocale()); var string = stringBundle.GetStringFromName("flock.blog.atom.error"); var fault = { faultString: string }; listener.onFault(fault); return; } } else { // OK, let's consider that it worked... listener.onResult(new Object()); return; } case 201: // The server returned the editURI + the entry var entry = flockAtomParseEntry (dom); listener.onResult(entry); break; case 303: // The server returned only the editURI var entry = new Object(); entry.editURI = inst._req.getResponseHeader('Location'); // TODO: do a GET to get the full entry listener.onResult(entry); break; case 400: // Invalid request var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"].getService(Components.interfaces.nsILocaleService); var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].getService(Components.interfaces.nsIStringBundleService); var stringBundle = stringBundleService.createBundle("chrome://flock/locale/blog/blog.properties", localeService.getApplicationLocale()); var string = stringBundle.GetStringFromName("flock.blog.atom.error"); var error = Cc['@flock.com/error;1'].createInstance(Ci.flockIError); error.serviceErrorCode = 400; error.serviceErrorString = string; listener.onFault(error); break; case 401: // Token disabled/expired var error = Cc['@flock.com/error;1'].createInstance(Ci.flockIError); error.serviceErrorCode = 401; error.serviceErrorString = inst._req.responseText; listener.onFault(error); break; case 403: // Account disabled/expired var error = Cc['@flock.com/error;1'].createInstance(Ci.flockIError); error.serviceErrorCode = 403; error.serviceErrorString = inst._req.responseText; listener.onFault(error); break; case 500: // Server internal error var error = Cc['@flock.com/error;1'].createInstance(Ci.flockIError); error.serviceErrorCode = 500; error.serviceErrorString = inst._req.responseText; listener.onError(error); break; default: // The server should not return any other code break; } } var flockAtomDoRequest = function(listener, url, method, entry, auth) { var inst = this; this._req = Components.classes['@mozilla.org/xmlextras/xmlhttprequest;1'].createInstance(Components.interfaces.nsIXMLHttpRequest); this._req.onreadystatechange = function (aEvt) { if(inst._req.readyState == 4) { try { dump("STATUS = "+inst._req.status+"\n"); switch (inst._req.status) { case 200: case 201: case 205: flockAtomParsePosts (listener, inst); break; case 401: // Token disabled/expired/invalid var error = Cc['@flock.com/error;1'].createInstance(Ci.flockIError); error.serviceErrorCode = 401; error.serviceErrorString = inst._req.responseText; listener.onFault(error); break; case 403: // Account disabled/expired/invalid var error = Cc['@flock.com/error;1'].createInstance(Ci.flockIError); error.serviceErrorCode = 403; error.serviceErrorString = inst._req.responseText; listener.onFault(error); break; case 500: // Server internal error var error = Cc['@flock.com/error;1'].createInstance(Ci.flockIError); error.serviceErrorCode = 500; error.serviceErrorString = inst._req.responseText; listener.onError(error); break; default: // The server should not return any other code break; } } catch(e) { dump(e); // listener.onError(inst.ERROR_PARSER); } } }; if (auth instanceof Array) { // username/password //dump("Launch query with "+auth[0]+" "+auth[1]+"\n"); rval = this._req.open(method, url, true, auth[0], auth[1]); } else { // Google auth rval = this._req.open(method, url, true); this._req.setRequestHeader("Authorization", "GoogleLogin auth="+auth); } this._req.setRequestHeader("Content-Type", "application/atom+xml"); //dump(">>>>>>>>>> Atom API: FLOCK TO SERVER\n"); //dump("\nSENDING\n" + entry.toXMLString()); //dump("\nTO\n" + method + " @ " + url + "\n"); rval = this._req.send('\n'+entry.toXMLString ()); } PK 3#78==content/flock/blog/blank.html
PK vA$7a8yy$content/flock/blog/blogAccountDlg.js// BEGIN FLOCK GPL // // Copyright Flock Inc. 2005-2007 // http://flock.com // // This file may be used under the terms of of the // GNU General Public License Version 2 or later (the "GPL"), // http://www.gnu.org/licenses/gpl.html // // Software distributed under the License is distributed on an "AS IS" basis, // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License // for the specific language governing rights and limitations under the // License. // // END FLOCK GPL Cc = Components.classes; Ci = Components.interfaces; var acUtils = Cc["@flock.com/account-utils;1"].getService(Ci.flockIAccountUtils); var gAccount; var gBlog; /* * Coop stuff */ var faves_coop = Components.classes["@flock.com/singleton;1"] .getService(Components.interfaces.flockISingleton) .getSingleton("chrome://flock/content/common/load-faves-coop.js") .wrappedJSObject; var gOrigBlog; var blogService = Components.classes['@flock.com/flock-blog;1'] .getService(Components.interfaces['flockIBlogService']); function onLoad() { // Populate the drop-down var list = $("blog-api-popup"); var webServices = blogService.services; while(webServices.hasMoreElements()) { var svc = webServices.getNext(); svc.QueryInterface(Components.interfaces.flockICustomBlogWebService); svc.QueryInterface(Components.interfaces.nsIClassInfo); var menuitem = document.createElement("menuitem"); menuitem.setAttribute('label', svc.name); menuitem.setAttribute('value', svc.contractID); list.appendChild(menuitem); } params = window.arguments[0]; gOrigBlog = params.accountId; window.setTimeout("fillFields();",0); } function fillFields() { var urn = gOrigBlog; dump("Filling for "+gOrigBlog+"\n"); gAccount = faves_coop.get(urn); $("blog-title").value = gAccount.name; $("blog-username").value = gAccount.accountId; try { $("blog-password").value = acUtils.getPassword(gOrigBlog).password; } catch (ex) { $("blog-password").value = ""; } var blogList = $("blog-list"); var blogListPopup = $("blog-list-popup"); var myEnum = gAccount.children.enumerate(); while (myEnum.hasMoreElements()) { var child = myEnum.getNext(); if (child.isInstanceOf(faves_coop.Blog)) { var item = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuitem"); item.setAttribute("id", child.id()); item.setAttribute("label", child.name); item.setAttribute("oncommand", "updateBlog();"); blogListPopup.appendChild(item); } } $("blog-list").selectedIndex = 0; updateBlog(); updateDropdown(gAccount.serviceId); } function updateBlog() { gBlog = faves_coop.get($("blog-list").selectedItem.id); dump("Selected "+gBlog.id()+"\n"); $("blog-blogid").value = gBlog.blogid; $("blog-uri").value = gBlog.apiLink; } function updateDropdown(apiname) { dump("Switching to "+apiname+"\n"); $("blog-api-menu").value = apiname; } function validateAccount() { var name = $("blog-api-menu").value; var strbundle = document.getElementById("blogStringBundle"); if(name=="unknown") { return strbundle.getString("flock.blog.account.select"); } var t = $("blog-title").value; if(t == "") { return strbundle.getString("flock.blog.account.title"); } return null; } function saveAccount() { var msg = validateAccount(); if(msg) { alert(msg); return; } var t = $("blog-title").value; // var bloguri = FLOCK_BLOG_RDF_SETTINGS + ":" + t; var u = $("blog-username").value; var p = $("blog-password").value; var b = $("blog-blogid").value; var uri = $("blog-uri").value; var apiName = $("blog-api-menu").selectedItem.value; gAccount.accountId = u; gAccount.serviceId = apiName; gBlog.blogid = b; gBlog.apiLink = uri; acUtils.setPassword(gOrigBlog, u, p); window.close(); } PK vA$7;UV V %content/flock/blog/blogAccountDlg.xul %flockBlogDTD; ]>