2010-08-03 11:12:14 +00:00
/ * *
* Global instance stored here
* /
var xmlRpcClient ;
//Service name on server like /common,/db etc...
var strServerService ;
//temporary variables
var strobject ;
//Array
var arrDbList = new Array ( ) ;
var arrPartnerList = new Array ( ) ;
var arrFinalList = new Array ( ) ;
var contentType = new Array ( ) ;
var uri = new Array ( ) ;
var url = new Array ( ) ;
var name = new Array ( ) ;
var attach _eml = "no" ;
var popup _display = "yes"
var rpc = {
servers : { } ,
2010-08-06 08:53:08 +00:00
addserver : function ( name , ip , port , path ) {
2010-08-03 11:12:14 +00:00
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
this . servers [ name ] = {
ip : ip ,
port : port ,
path : path ,
avaible : true ,
sock : Components . classes [ '@mozilla.org/xml-rpc/client;1' ] . createInstance ( Components . interfaces . nsIXmlRpcClient ) } ;
} ,
getany : function ( rpcval , n ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var t = [ 'PRUint8' , 'PRUint16' , 'PRInt16' , 'PRInt32' , 'PRBool' , 'Char' , 'CString' , 'Float' , 'Double' , 'PRTime' , 'InputStream' , 'Array' , 'Dictionary' ] ;
for ( var i = 0 ; i < t . length ; i ++ )
try { return [ t [ i ] , this . Iget ( rpcval , Components . interfaces [ ( ( i == 10 || i == 12 ) ? 'nsI' : 'nsISupports' ) + t [ i ] ] , n ) ] ; } catch ( e ) { }
return [ false , 'error getany' , 'Undefined type' ] ;
} ,
onfault : function ( t ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
return ( t . constructor == Array && t . length == 3 && ! t [ 0 ] && ( t [ 1 ] . substr ( 0 , 5 ) == 'error' || t [ 1 ] . substr ( 0 , 5 ) == 'fault' ) ) ?
true : false ;
} ,
getall : function ( rpcval , n ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var t = this . getany ( rpcval , n ) ;
if ( this . onfault ( t ) ) return t ;
if ( t [ 0 ] == 'PRBool' ) return ( t [ 1 ] == 'true' ) ;
if ( t [ 0 ] == 'PRInt32' ) return parseInt ( t [ 1 ] + '' ) ;
if ( t [ 0 ] == 'PRTime' ) {
dte = new Date ( "January 1, 1970, 00:00:00" ) ;
dte . setUTCMilliseconds ( t [ 1 ] + '' ) ;
return dte ; }
if ( t [ 0 ] == 'Double' || t [ 0 ] == 'Float' ) return parseFloat ( t [ 1 ] + '' ) ;
if ( t [ 0 ] == 'Char' || t [ 0 ] == 'CString' ) return ( t [ 1 ] + '' ) . replace ( /¬/g , '€' ) ;
if ( t [ 0 ] == 'Array' ) {
var a = [ ] ;
for ( var i = 0 ; i < t [ 1 ] . Count ( ) ; i ++ ) a [ i ] = this . getall ( t [ 1 ] , i ) ;
} else if ( t [ 0 ] == 'Dictionary' ) {
var a = { } ;
var keys = t [ 1 ] . getKeys ( { } ) ;
for ( var k = 0 ; k < keys . length ; k ++ )
a [ keys [ k ] ] = this . getall ( t [ 1 ] , keys [ k ] ) ;
} else return t [ 1 ] ;
return a ;
} ,
Iget : function ( rpcval , itype , n ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
if ( n == undefined ) return rpcval . QueryInterface ( itype ) ;
else if ( n == parseInt ( n ) ) return rpcval . QueryElementAt ( n , itype ) ;
else return rpcval . getValue ( n ) . QueryInterface ( itype ) ;
} ,
checktype : function ( val ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
if ( val != undefined ) {
switch ( val . constructor ) {
case Number : return ( val == parseInt ( val ) ) ? 1 : 4 ;
case Boolean : return 2 ;
case String : return 3 ;
case Date : return 5 ;
case Object : return 7 ;
case Array : return 6 ;
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
}
}
return 7 ;
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
} ,
set : function ( rpcobj , param ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
if ( param == undefined ) return [ false , 'error set' , 'Undefined parameter' ] ;
var itype = this . checktype ( param ) ;
if ( this . onfault ( itype ) ) return itype ;
var p = this . servers [ rpcobj ] . sock . createType ( itype , { } ) ;
if ( itype == 6 ) {
if ( param . length > 0 )
for ( var i = 0 ; i < param . length ; i ++ ) p . AppendElement ( this . set ( rpcobj , param [ i ] ) ) ;
} else if ( itype == 7 ) {
for ( var i in param ) p . setValue ( i , this . set ( rpcobj , param [ i ] ) ) ;
} else if ( itype == 4 ) {
p . data = ( '' + param ) . replace ( ',' , '.' ) ;
} else p . data = param ;
return p ;
} ,
ask : function ( rpcobj , method , params , func _out ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var a = this . disableNset ( rpcobj ) ;
if ( this . onfault ( a ) ) return a ;
var handler = {
onResult : function ( client , async , result ) {
rpc . servers [ rpcobj ] . avaible = true ;
func _out ( rpc . getall ( result ) ) ; } ,
onFault : function ( client , async , faute ) { alert ( "in ask infault" + result )
rpc . servers [ rpcobj ] . avaible = true ; func _out ( [ false , 'fault' , faute ] ) ; } ,
onError : function ( client , async , status , msg ) {
rpc . servers [ rpcobj ] . avaible = true ;
if ( status == '2147500037' ) {
status = "no network or no server" ;
msg = "1. Check your network connection." ;
msg += "\n2. Check your server connection parameters:" ;
msg += "\n\t" + rpc . servers [ rpcobj ] . ip + ":" + rpc . servers [ rpcobj ] . port + "=>" + params [ 0 ] ;
msg += "\n3. Your server may not be launched or connected to the network." ;
}
func _out ( [ false , 'error ' + status , msg ] ) ;
} } ;
var p = [ ] ;
for ( var i = 0 ; i < params . length ; i ++ )
p [ i ] = this . set ( rpcobj , params [ i ] ) ;
try { this . servers [ rpcobj ] . sock . asyncCall ( handler , null , method , p , p . length ) ;
} catch ( e ) {
this . servers [ rpcobj ] . avaible = true ;
this . servers [ rpcobj ] . sock = Components . classes [ '@mozilla.org/xml-rpc/client;1' ] . createInstance ( Components . interfaces . nsIXmlRpcClient ) ;
func _out ( [ false , 'error catch' , e ] ) ; }
return true ;
} ,
disableNset : function ( rpcobj ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
if ( this . servers [ rpcobj ] ) {
this . servers [ rpcobj ] . avaible = false ; //alert('http://'+this.servers[rpcobj].ip+':'+this.servers[rpcobj].port+this.servers[rpcobj].path);
server _path = this . servers [ rpcobj ] . ip + ':' + this . servers [ rpcobj ] . port + this . servers [ rpcobj ] . path
this . servers [ rpcobj ] . sock . init ( server _path ) ;
return true ; }
return [ false , 'error disableNset' , 'Server vars not set' ] ;
}
}
function handler _function ( result ) {
if ( rpc . onfault ( result ) ) { alert ( result [ 0 ] + "\n" + result [ 1 ] ) ; return ; }
else {
alert ( "got result>>>>" + result )
}
}
//Sets the preference service
function getPref ( ) {
var prefService = Components . classes [ "@mozilla.org/preferences-service;1" ] . getService ( Components . interfaces . nsIPrefService ) ;
var branchobj = prefService . getBranch ( "extensions.tiny." ) ;
branchobj . QueryInterface ( Components . interfaces . nsIPrefBranch2 ) ;
return branchobj
}
function setFileName ( fname ) {
getPref ( ) . setCharPref ( 'fname' , fname ) ;
}
//set attachment file save or not
function setAttachment ( argAttac ) {
getPref ( ) . setCharPref ( 'attachment' , argAttac ) ;
}
//set preference value for server url
function setServer ( argServer ) {
getPref ( ) . setCharPref ( 'serverurl' , argServer ) ;
}
//set preference value for server port
function setPort ( argPort ) {
getPref ( ) . setCharPref ( 'serverport' , argPort )
}
//set preference value of database name for data searching and selection
function setDbName ( argDbName ) {
getPref ( ) . setCharPref ( 'serverdbname' , argDbName ) ;
}
//set preference value of username for login
function setUsername ( argUsername ) {
getPref ( ) . setCharPref ( 'username' , argUsername ) ;
}
//set preference value of password for login
function setPassword ( argPassword ) {
getPref ( ) . setCharPref ( 'password' , argPassword ) ;
}
//set preference value for storing partner id
function setPartnerId ( argPartnerId ) {
getPref ( ) . setCharPref ( 'partnerid' , argPartnerId )
}
//set preference value for Resource Id
function setResourceId ( argResourceId ) {
getPref ( ) . setCharPref ( 'res_id' , argResourceId )
}
//set server service
function setServerService ( argServerService ) {
strServerService = argServerService ;
}
//set preference value for sender email
function setSenderEmail ( argSenderEmail ) {
getPref ( ) . setCharPref ( 'senderemail' , argSenderEmail )
}
//set preference value for receiver email
function setReceiverEmail ( argReceiverEmail ) {
getPref ( ) . setCharPref ( 'receiveremail' , argReceiverEmail )
}
//set preference value for sender name
function setSenderName ( argSenderName ) {
getPref ( ) . setCharPref ( 'sendername' , argSenderName )
}
//set preference value for email subject
function setSubject ( argSubject ) {
getPref ( ) . setCharPref ( 'subject' , argSubject )
}
//set preference value for email received date
function setReceivedDate ( argReceivedDate ) {
getPref ( ) . setCharPref ( 'receiveddate' , argReceivedDate )
}
//set preference value for storing contact id which is used while storing mail contents after creating a new partner contact
function setContactId ( argContactId ) {
getPref ( ) . setCharPref ( 'contactid' , argContactId )
}
//set preference value for storing attachment option in config
function setAttachValue ( argAttachValue ) {
getPref ( ) . setCharPref ( 'attachvalue' , argAttachValue )
}
//set preference value for email cclist
function setCCList ( argCCList ) {
getPref ( ) . setCharPref ( 'cclist' , argCCList )
}
//set preference value for email message body
function setMessageBody ( argMessageBody ) {
getPref ( ) . setCharPref ( 'messagebody' , argMessageBody )
}
//set preference value for Partner Name
function setPartnerName ( argPartnerName ) {
getPref ( ) . setCharPref ( 'partnername' , argPartnerName )
}
//set preference value for Contact Name
function setContactName ( argContactName ) {
getPref ( ) . setCharPref ( 'contactname' , argContactName )
}
//set preference value for street
function setStreet ( argStreet ) {
getPref ( ) . setCharPref ( 'street' , argStreet )
}
//set preference value for street2
function setStreet2 ( argStreet2 ) {
getPref ( ) . setCharPref ( 'street2' , argStreet2 )
}
//set preference value for zipcode
function setZipCode ( argZipcode ) {
getPref ( ) . setCharPref ( 'zipcode' , argZipcode )
}
//set preference value for Office Number
function setOfficenumber ( argOfficenumber ) {
getPref ( ) . setCharPref ( 'officeno' , argOfficenumber )
}
//set preference value for Phone Number
function setMobilenumber ( argMobilenumber ) {
getPref ( ) . setCharPref ( 'phoneno' , argMobilenumber )
}
//set preference value for Fax
function setFax ( argFax ) {
getPref ( ) . setCharPref ( 'fax' , argFax )
}
//set preference value for city
function setCity ( argCity ) {
getPref ( ) . setCharPref ( 'city' , argCity )
}
//set preference value for country
function setCountry ( argCountry ) {
2010-08-06 08:05:45 +00:00
getPref ( ) . setCharPref ( 'country' , argCountry )
2010-08-03 11:12:14 +00:00
}
//set preference value for state
function setState ( argState ) {
getPref ( ) . setCharPref ( 'state' , argState )
}
//set the value for the whole server url
function setServerUrl ( argServerUrl )
{
var seperateUrl = argServerUrl . split ( ':' ) ;
setServer ( seperateUrl . slice ( 0 , seperateUrl . length - 1 ) . join ( ":" ) ) ;
setPort ( seperateUrl [ seperateUrl . length - 1 ] ) ;
}
//set preference value for storing user id
function setUserId ( argUserId ) {
getPref ( ) . setIntPref ( 'userid' , argUserId ) ;
}
//set database list is displaye or not
function setDBList ( argDBList ) {
getPref ( ) . setCharPref ( 'db_list' , argDBList )
}
//set server connect or not
function setconnect _server ( argconnect _server ) {
getPref ( ) . setCharPref ( 'connect_server' , argconnect _server )
}
//set module install or not
function setmodule _install ( argconnect _module ) {
getPref ( ) . setCharPref ( 'module_install' , argconnect _module )
}
//get module install or not
function getmodule _install ( ) {
return getPref ( ) . getCharPref ( 'module_install' ) ;
}
//get server connect or not
function getconnect _server ( ) {
return getPref ( ) . getCharPref ( 'connect_server' ) ;
}
//get partner id
function getPartnerId ( ) {
return getPref ( ) . getCharPref ( 'partnerid' ) ;
}
//get database list is displaye or not
function getDBList ( ) {
return getPref ( ) . getCharPref ( 'db_list' ) ;
}
function getFileName ( ) {
return getPref ( ) . getCharPref ( 'fname' ) ;
}
//get attachment save or not
function getAttachment ( ) {
return getPref ( ) . getCharPref ( 'attachment' ) ;
}
//get serverurl
function getServer ( ) {
return getPref ( ) . getCharPref ( 'serverurl' ) ;
}
//get server port
function getPort ( ) {
return getPref ( ) . getCharPref ( 'serverport' ) ;
}
//get database name
function getDbName ( ) {
return getPref ( ) . getCharPref ( 'serverdbname' ) ;
}
//get username from config settings
function getUsername ( ) {
return getPref ( ) . getCharPref ( 'username' ) ;
}
//get password from config settings
function getPassword ( ) {
return getPref ( ) . getCharPref ( 'password' ) ;
}
//get serverservice
function getServerService ( ) {
return strServerService ;
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
}
//get sender email
function getSenderEmail ( ) {
return getPref ( ) . getCharPref ( 'senderemail' ) ;
}
//get receiver email
function getReceiverEmail ( ) {
return getPref ( ) . getCharPref ( 'receiveremail' ) ;
}
//get resource id
function getResourceId ( ) {
return getPref ( ) . getCharPref ( 'res_id' ) ;
}
//get sender name
function getSenderName ( ) {
str = getPref ( ) . getCharPref ( 'sendername' ) ;
if ( ! str . toString ( ) . match ( /=?utf-8?q?/ ) )
{
return str ;
}
else
{
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
string = str . replace ( /[\'Š',\'Ž',\'š',\'ž',\'Ÿ',\'À',\'Á',\'Â',\'Ã',\'Ä',\'Å',\'Ç',\'È',\'É',\'Ê',\'Ë',\'Ì',\'Í',\'Î',\'Ï',\'Ñ',\'Ò',\'Ó',\'Ô',\'Õ',\'Ö',\'Ø',\'Ù',\'Ú',\'Û',\'Ü',\'Ý',\'à',\'á',\'â',\'ã',\'ä',\'å',\'ç',\'è',\'é',\'ê',\'ë',\'ì',\'í',\'î',\'ï',\'ñ',\'ò',\'ó',\'ô',\'õ',\'ö',\'ø',\'ù',\'ú',\'û',\'ü',\'ý',\'ÿ',\'Þ',\'þ',\'Ð',\'ð',\'ß',\'Œ',\'œ',\'Æ',\'æ',\'µ']/g , '"' , "'" , '“' , '”' , "\n" , "\r" , '_/' , "'S','Z','s','z','Y','A','A','A','A','A','A','C','E','E','E','E','I','I','I','I','N','O','O','O','O','O','O','U','U','U','U','Y','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i','n','o','o','o','o','o','o','u','u','u','u','y','y','TH','th','DH','dh','ss','OE','oe','AE','ae','u','','','','','','','-'" ) ;
var utftext = "" ;
var encoded _string = "" ;
var convertedString = "" ;
for ( var n = 0 ; n < string . length ; n ++ )
{
var c = string . charCodeAt ( n ) ;
if ( c < 128 ) {
utftext += String . fromCharCode ( c ) ;
}
}
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
encoded _string = encode64 ( utftext ) ;
return encoded _string ;
}
}
//ger partner name
function getPartnerName ( ) {
return getPref ( ) . getCharPref ( 'partnername' ) ;
}
//get contact name
function getContactName ( ) {
return getPref ( ) . getCharPref ( 'contactname' ) ;
}
//get street name
function getStreet ( ) {
return getPref ( ) . getCharPref ( 'street' ) ;
}
//get street2 name
function getStreet2 ( ) {
return getPref ( ) . getCharPref ( 'street2' ) ;
}
//get zip code
function getZipCode ( ) {
return getPref ( ) . getCharPref ( 'zipcode' ) ;
}
//get city name
function getCity ( ) {
return getPref ( ) . getCharPref ( 'city' ) ;
}
//get country name
function getCountry ( ) {
return getPref ( ) . getCharPref ( 'country' ) ;
}
//get state name
function getState ( ) {
return getPref ( ) . getCharPref ( 'state' ) ;
}
//get office no
function getOfficenumber ( ) {
return getPref ( ) . getCharPref ( 'officeno' ) ;
}
//get mobile no
function getMobilenumber ( ) {
return getPref ( ) . getCharPref ( 'phoneno' ) ;
}
//get fax no
function getFax ( ) {
return getPref ( ) . getCharPref ( 'fax' ) ;
}
//get email subject
function getSubject ( ) {
return getPref ( ) . getCharPref ( 'subject' ) ;
}
//get email received date
function getReceivedDate ( ) {
return getPref ( ) . getCharPref ( 'receiveddate' ) ;
}
//get contact id which is used while storing mail contents after creating a new partner contact
function getContactId ( ) {
return getPref ( ) . getCharPref ( 'contactid' ) ;
}
//get attachment option information from the configuration settings
function getAttachValue ( ) {
return getPref ( ) . getCharPref ( 'attachvalue' ) ;
}
//get email cclist information
function getCCList ( ) {
return getPref ( ) . getCharPref ( 'cclist' ) ;
}
//get email message body
function getMessageBody ( ) {
return getPref ( ) . getCharPref ( 'messagebody' ) ;
}
//get the whole server path
function getServerUrl ( ) {
return getServer ( ) + ":" + getPort ( ) + "/" + getServerService ( ) ;
}
//get user id for the xmlrpc request
function getUserId ( ) {
return getPref ( ) . getIntPref ( 'userid' ) ;
}
//Creates and returns and instance of the XML-RPC client
function getClient ( ) {
// Enable correct security
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
return Components . classes [ '@mozilla.org/xml-rpc/client;1' ] . createInstance ( Components . interfaces . nsIXmlRpcClient ) ;
}
//returns the xmlrpc client instance
function getXmlRpc ( ) {
if ( ! xmlRpcClient ) {
xmlRpcClient = getClient ( ) ;
}
// Initialize the client with the URL
xmlRpcClient . init ( getServerUrl ( ) ) ;
return xmlRpcClient ;
}
// function to get all basic parameters
function getBasicList ( ) {
var branchobj = getPref ( ) ;
arrBasicList = [ ] ;
arrBasicList [ 0 ] = branchobj . getCharPref ( "serverdbname" ) ;
arrBasicList [ 1 ] = branchobj . getIntPref ( 'userid' ) ;
arrBasicList [ 2 ] = branchobj . getCharPref ( "password" ) ;
arrBasicList [ 3 ] = getServer ( )
arrBasicList [ 4 ] = getPort ( )
return arrBasicList
}
function createMenuItem _db ( aLabel ) {
const XUL _NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" ;
var item = document . createElementNS ( XUL _NS , "menuitem" ) ; // create a new XUL menuitem
item . setAttribute ( "label" , aLabel ) ;
item . setAttribute ( "value" , aLabel ) ;
return item ;
}
//xmlrpc request handler for getting the list of database
var listDbHandler = {
onResult : function ( client , context , result ) {
setconnect _server ( "true" )
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var arrMethodList = result . QueryInterface ( Components . interfaces . nsISupportsArray ) ;
2010-08-06 08:05:45 +00:00
// Set the number of results
2010-08-03 11:12:14 +00:00
var count = arrMethodList . Count ( ) ;
// Loop through the results, adding items to the list
for ( i = 0 ; i < count ; i ++ ) {
var strlDbName = arrMethodList . QueryElementAt ( i , Components . interfaces . nsISupportsCString ) ;
arrDbList [ i ] = strlDbName . data ;
}
var database = ""
if ( count > 0 )
{
setDBList ( "true" )
var label = document . getElementById ( "database_option" ) ;
var vbox = document . createElement ( "vbox" ) ;
var hbox = document . createElement ( "hbox" ) ;
var label1 = document . createElement ( "label" ) ;
label1 . setAttribute ( "width" , "80" ) ;
label1 . setAttribute ( "value" , "Database" ) ;
label1 . setAttribute ( "id" , "label111" ) ;
var menu1 = document . createElement ( "menulist" ) ;
var menupopup1 = document . createElement ( "menupopup" ) ;
menu1 . setAttribute ( "id" , "DBlist" ) ;
menu1 . setAttribute ( "width" , "300" ) ;
var menuitem1 = document . createElement ( "menuitem" ) ;
database = arrDbList [ 0 ]
menuitem1 . setAttribute ( "label" , arrDbList [ 0 ] ) ;
menuitem1 . setAttribute ( "value" , arrDbList [ 0 ] ) ;
menupopup1 . appendChild ( menuitem1 ) ;
menu1 . appendChild ( menupopup1 )
hbox . appendChild ( label1 ) ;
hbox . appendChild ( menu1 ) ;
vbox . appendChild ( hbox ) ;
label . appendChild ( vbox ) ;
var d = document . getElementById ( "first" ) ;
var d _nested = document . getElementById ( "lbldb_list1" ) ;
var throwawayNode = d . removeChild ( d _nested ) ;
var d _nested = document . getElementById ( "DBlist_text" ) ;
var throwawayNode = d . removeChild ( d _nested ) ;
}
else
{
setDBList ( "false" )
}
// Loop through the results, adding items to the list
if ( count )
{
const XUL _NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" ;
2010-08-06 08:05:45 +00:00
var popup = document . getElementById ( "DBlist" ) ; // a <menupopup> element
2010-08-03 11:12:14 +00:00
var arrsec = new Array ( )
for ( var i = 0 ; i < popup . menupopup . childNodes . length ; i ++ ) {
arrsec . push ( popup . menupopup . childNodes [ i ] . label )
}
for ( i = 0 ; i < arrDbList . length ; i ++ ) {
if ( arrsec . indexOf ( arrDbList [ i ] ) == - 1 ) {
if ( arrDbList [ i ] != database ) {
popup . menupopup . appendChild ( createMenuItem _db ( arrDbList [ i ] ) ) ;
}
}
}
}
} ,
onFault : function ( client , ctxt , fault ) {
} ,
onError : function ( client , ctxt , status , errorMsg ) {
}
} ;
//function to get the database list
function getDbList ( argControl )
{
setDBList ( "false" )
setconnect _server ( "false" )
2010-08-06 08:05:45 +00:00
// Enable correct security
2010-08-03 11:12:14 +00:00
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
// Get the instance of the XML-RPC client
var xmlRpcClient = getXmlRpc ( ) ;
arrDbList = [ ] ;
var cmbDbList = document . getElementById ( argControl ) ;
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
xmlRpcClient . asyncCall ( listDbHandler , cmbDbList , 'list' , [ ] , 0 ) ;
return arrDbList ;
}
function createMenuItem _partner ( aLabel , aValue ) {
const XUL _NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" ;
2010-08-06 08:05:45 +00:00
var item = document . createElementNS ( XUL _NS , "menuitem" ) ; // create a new XUL menuitem
2010-08-03 11:12:14 +00:00
item . setAttribute ( "label" , aLabel ) ;
item . setAttribute ( "value" , aValue ) ;
return item ;
}
//xmlrpc request handler for getting the list of All objects
var listAllDocumentHandler = {
onResult : function ( client , context , result ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var arrIdList = result . QueryInterface ( Components . interfaces . nsISupportsArray ) ;
2010-08-06 08:05:45 +00:00
// Set the number of results
2010-08-03 11:12:14 +00:00
var count = arrIdList . Count ( ) ;
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
// Loop through the results, adding items to the list
for ( i = 0 ; i < count ; i ++ ) {
var strlResult = arrIdList . QueryElementAt ( i , Components . interfaces . nsISupportsArray ) ;
var resultcount = strlResult . Count ( ) ;
var arrDataPair = new Array ( ) ;
arrDataPair [ 0 ] = strlResult . QueryElementAt ( 0 , Components . interfaces . nsISupportsCString ) ;
arrDataPair [ 1 ] = strlResult . QueryElementAt ( 1 , Components . interfaces . nsISupportsCString ) ;
arrPartnerList [ i ] = arrDataPair ;
}
if ( context )
{
const XUL _NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" ;
2010-08-06 08:05:45 +00:00
var popup = document . getElementById ( "section" ) ; // a <menupopup> element
2010-08-03 11:12:14 +00:00
for ( i = 0 ; i < arrPartnerList . length ; i ++ ) {
popup . menupopup . appendChild ( createMenuItem _partner ( arrPartnerList [ i ] [ 1 ] , arrPartnerList [ i ] [ 0 ] ) ) ;
}
}
popup _display = "no"
searchCheckbox ( )
} ,
onFault : function ( client , ctxt , fault ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
} ,
onError : function ( client , ctxt , status , errorMsg ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
}
}
var listAllCountryHandler = {
onResult : function ( client , context , result ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var arrIdList = result . QueryInterface ( Components . interfaces . nsISupportsArray ) ;
var count = arrIdList . Count ( ) ;
// Loop through the results, adding items to the list
for ( i = 0 ; i < count ; i ++ ) {
var strlResult = arrIdList . QueryElementAt ( i , Components . interfaces . nsISupportsArray ) ;
var resultcount = strlResult . Count ( ) ;
var arrDataPair = new Array ( ) ;
arrDataPair [ 0 ] = strlResult . QueryElementAt ( 0 , Components . interfaces . nsISupportsPRInt32 ) ;
arrDataPair [ 1 ] = strlResult . QueryElementAt ( 1 , Components . interfaces . nsISupportsCString ) ;
arrPartnerList [ i ] = arrDataPair ;
}
if ( ! context )
{
const XUL _NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" ;
2010-08-06 08:05:45 +00:00
var popup = document . getElementById ( "country" ) ; // a <menupopup> element
2010-08-03 11:12:14 +00:00
for ( i = 0 ; i < arrPartnerList . length ; i ++ ) {
popup . menupopup . appendChild ( createMenuItem _partner ( arrPartnerList [ i ] [ 1 ] , arrPartnerList [ i ] [ 0 ] ) ) ;
}
}
} ,
onFault : function ( client , ctxt , fault ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
} ,
onError : function ( client , ctxt , status , errorMsg ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
}
}
var listAllStateHandler = {
onResult : function ( client , context , result ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var arrIdList = result . QueryInterface ( Components . interfaces . nsISupportsArray ) ;
2010-08-06 08:05:45 +00:00
// Set the number of results
2010-08-03 11:12:14 +00:00
var count = arrIdList . Count ( ) ;
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
// Loop through the results, adding items to the list
for ( i = 0 ; i < count ; i ++ ) {
var strlResult = arrIdList . QueryElementAt ( i , Components . interfaces . nsISupportsArray ) ;
var resultcount = strlResult . Count ( ) ;
var arrDataPair = new Array ( ) ;
arrDataPair [ 0 ] = strlResult . QueryElementAt ( 0 , Components . interfaces . nsISupportsPRInt32 ) ;
arrDataPair [ 1 ] = strlResult . QueryElementAt ( 1 , Components . interfaces . nsISupportsCString ) ;
arrPartnerList1 [ i ] = arrDataPair ;
}
if ( ! context )
{
const XUL _NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" ;
var popup = document . getElementById ( "state" ) ;
2010-08-06 08:05:45 +00:00
// a <menupopup> element
2010-08-03 11:12:14 +00:00
for ( i = 0 ; i < arrPartnerList1 . length ; i ++ ) {
popup . menupopup . appendChild ( createMenuItem _partner ( arrPartnerList1 [ i ] [ 1 ] , arrPartnerList1 [ i ] [ 0 ] ) ) ;
}
}
} ,
onFault : function ( client , ctxt , fault ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
} ,
onError : function ( client , ctxt , status , errorMsg ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
}
}
//function to get the list of All object
function getAllDocument ( ) {
var branchobj = getPref ( ) ;
setServerService ( 'xmlrpc/object' ) ;
var xmlRpcClient = getXmlRpc ( ) ;
arrPartnerList = [ ] ;
var end = document . getElementById ( "section" )
length = end . itemCount
for ( i = 0 ; i < length ; i ++ ) {
end . removeItemAt ( 0 )
}
var cmdObjectList = document . getElementById ( "section" ) ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = branchobj . getCharPref ( "serverdbname" ) ;
var struid = xmlRpcClient . createType ( xmlRpcClient . INT , { } ) ;
struid . data = branchobj . getIntPref ( 'userid' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = branchobj . getCharPref ( "password" ) ;
var strmethod = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strmethod . data = 'list_alldocument' ;
var strobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strobj . data = 'thunderbird.partner' ;
var strvalue = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
2010-08-06 08:53:08 +00:00
strvalue . data = ""
2010-08-03 11:12:14 +00:00
xmlRpcClient . asyncCall ( listAllDocumentHandler , cmdObjectList , 'execute' , [ strDbName , struid , strpass , strobj , strmethod , strvalue ] , 6 ) ;
}
function getAllCountry ( ) {
var branchobj = getPref ( ) ;
setServerService ( 'xmlrpc/object' ) ;
var xmlRpcClient = getXmlRpc ( ) ;
arrPartnerList = [ ] ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = branchobj . getCharPref ( "serverdbname" ) ;
var struid = xmlRpcClient . createType ( xmlRpcClient . INT , { } ) ;
struid . data = branchobj . getIntPref ( 'userid' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = branchobj . getCharPref ( "password" ) ;
var strmethod = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strmethod . data = 'list_allcountry' ;
var strobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strobj . data = 'thunderbird.partner' ;
var strvalue = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strvalue . data = document . getElementById ( "country" ) . value ;
xmlRpcClient . asyncCall ( listAllCountryHandler , null , 'execute' , [ strDbName , struid , strpass , strobj , strmethod , strvalue ] , 6 ) ;
}
function getAllState ( ) {
var branchobj = getPref ( ) ;
setServerService ( 'xmlrpc/object' ) ;
var xmlRpcClient = getXmlRpc ( ) ;
arrPartnerList1 = [ ] ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = branchobj . getCharPref ( "serverdbname" ) ;
var struid = xmlRpcClient . createType ( xmlRpcClient . INT , { } ) ;
struid . data = branchobj . getIntPref ( 'userid' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = branchobj . getCharPref ( "password" ) ;
var strmethod = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strmethod . data = 'list_allstate' ;
var strobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strobj . data = 'thunderbird.partner' ;
var strvalue = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strvalue . data = document . getElementById ( "state" ) . value ;
xmlRpcClient . asyncCall ( listAllStateHandler , null , 'execute' , [ strDbName , struid , strpass , strobj , strmethod , strvalue ] , 6 ) ;
}
//function to create array object to pass as an parameter for xmlrpc request
function dictcreation ( value , checkboxobj ) {
var temp = xmlRpcClient . createType ( xmlRpcClient . ARRAY , { } ) ;
var test = xmlRpcClient . createType ( xmlRpcClient . ARRAY , { } ) ;
var strkey = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strkey . data = value ;
test . AppendElement ( strkey ) ;
temp . AppendElement ( test ) ;
var test1 = xmlRpcClient . createType ( xmlRpcClient . ARRAY , { } ) ;
for ( i = 0 ; i < checkboxobj . length ; i ++ ) {
var strvalue = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strvalue . data = checkboxobj [ i ] ;
test1 . AppendElement ( strvalue ) ;
}
if ( checkboxobj . length > 0 ) {
temp . AppendElement ( test1 ) ;
}
return temp ;
}
//function to search and fillup section selection box
function createMenuItem ( aLabel ) {
const XUL _NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" ;
2010-08-06 08:05:45 +00:00
var item = document . createElementNS ( XUL _NS , "menuitem" ) ; // create a new XUL menuitem
2010-08-03 11:12:14 +00:00
item . setAttribute ( "label" , aLabel [ 1 ] ) ;
item . setAttribute ( "value" , aLabel [ 0 ] ) ;
return item ;
}
function listinstallmodule ( result ) {
if ( rpc . onfault ( result ) )
{
setmodule _install ( 'no' )
}
}
function module _install ( )
{
setmodule _install ( "yes" )
var branchobj = getPref ( ) ;
setServerService ( 'xmlrpc/object' ) ;
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var xmlRpcClient = getXmlRpc ( ) ;
strDbName = branchobj . getCharPref ( "serverdbname" ) ;
struid = branchobj . getIntPref ( 'userid' ) ;
strpass = branchobj . getCharPref ( "password" ) ;
strmethod = 'search' ;
strobj = 'thunderbird.partner' ; // TOFIX: Find module 'thunderbird' into 'module.module' model.
var temp = new Array ( )
server = getServer ( )
port = getPort ( )
basicList = getBasicList ( )
rpc . addserver ( 'object' , basicList [ 3 ] , basicList [ 4 ] , '/xmlrpc/object' ) ;
srcids = rpc . ask ( 'object' , 'execute' , [ basicList [ 0 ] , basicList [ 1 ] , basicList [ 2 ] , strobj , strmethod , [ ] ] , listinstallmodule )
}
var listSearchContactHandler = {
onResult : function ( client , context , result ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var arrIdList = result . QueryInterface ( Components . interfaces . nsISupportsArray ) ;
var count = arrIdList . Count ( ) ;
for ( i = 0 ; i < count ; i ++ ) {
var strlResult = arrIdList . QueryElementAt ( i , Components . interfaces . nsISupportsArray ) ;
var strlSearchResult = strlResult . QueryElementAt ( 0 , Components . interfaces . nsISupportsCString ) ;
var strlSearchResultValue = strlResult . QueryElementAt ( 1 , Components . interfaces . nsISupportsCString ) ;
if ( strlSearchResult == "partner_name" ) {
setPartnerName ( strlSearchResultValue ) ;
var t = getPartnerName ( ) ; }
if ( strlSearchResult == "contactname" ) {
setSenderName ( strlSearchResultValue ) ;
var t = getSenderName ( ) ; }
if ( strlSearchResult == "street" ) {
setStreet ( strlSearchResultValue ) ;
var t = getStreet ( ) ; }
if ( strlSearchResult == "street2" ) {
setStreet2 ( strlSearchResultValue ) ;
var t = getStreet2 ( ) ; }
if ( strlSearchResult == "zip" ) {
setZipCode ( strlSearchResultValue ) ;
var t = getZipCode ( ) ; }
if ( strlSearchResult == "city" ) {
setCity ( strlSearchResultValue ) ;
var t = getCity ( ) ; }
if ( strlSearchResult == "phone" ) {
setOfficenumber ( strlSearchResultValue ) ;
var t = getOfficenumber ( ) ; }
if ( strlSearchResult == "fax" ) {
setFax ( strlSearchResultValue ) ;
var t = getFax ( ) ; }
if ( strlSearchResult == "mobile" ) {
setMobilenumber ( strlSearchResultValue ) ;
var t = getMobilenumber ( ) ; }
if ( strlSearchResult == "email" ) {
setSenderEmail ( strlSearchResultValue ) ;
var t = getSenderEmail ( ) ; }
if ( strlSearchResult == "res_id" ) {
setResourceId ( strlSearchResultValue ) ;
var t = getResourceId ( ) ; }
}
} ,
onFault : function ( client , ctxt , fault ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
} ,
onError : function ( client , ctxt , status , errorMsg ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
}
}
//xmlrpc request handler for getting the search results for the particular selected check box object
var listSearchCheckboxHandler = {
onResult : function ( client , context , result ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var arrMethodList = result . QueryInterface ( Components . interfaces . nsISupportsArray ) ;
2010-08-06 08:05:45 +00:00
// Set the number of results
2010-08-03 11:12:14 +00:00
var count = arrMethodList . Count ( ) ;
var close = 0 ;
if ( count == 0 && popup _display != "no" ) {
alert ( "No records Found" ) ;
return false ;
}
else if ( count == 2 )
{
if ( arrMethodList . QueryElementAt ( 0 , Components . interfaces . nsISupportsCString ) == "error" )
{
close = 1 ;
}
}
popup _display = "yes"
// Loop through the results, adding items to the list
var arr1 = new Array ( ) ;
var arr2 = new Array ( ) ;
var flag1 = 0 ;
var flag2 = 0 ;
var er = "" ;
var er _val = new Array ( ) ;
for ( i = 0 ; i < count ; i ++ )
{
if ( i % 2 == 0 ) {
if ( arrMethodList . QueryElementAt ( i , Components . interfaces . nsISupportsCString ) == "error" )
{
er = arrMethodList . QueryElementAt ( i , Components . interfaces . nsISupportsCString ) ;
er _val [ 0 ] = arrMethodList . QueryElementAt ( i + 1 , Components . interfaces . nsISupportsArray ) ;
i += 1 ;
continue ;
}
arr1 [ flag1 ] = arrMethodList . QueryElementAt ( i , Components . interfaces . nsISupportsCString ) ;
flag1 ++ ;
}
else {
arr2 [ flag2 ] = arrMethodList . QueryElementAt ( i , Components . interfaces . nsISupportsArray ) ;
flag2 ++ ;
}
}
if ( er )
{
var arrSearchList1 = new Array ( ) ;
for ( j = 0 ; j < er _val [ 0 ] . Count ( ) ; j ++ )
{
var arrDataPair = new Array ( ) ;
arrDataPair [ 0 ] = er _val [ 0 ] . QueryElementAt ( j , Components . interfaces . nsISupportsCString )
arrSearchList1 [ j ] = arrDataPair ;
}
alert ( arrSearchList1 + " model not exists" )
if ( close == 1 )
{
alert ( "No records Found" ) ;
return false ;
}
}
for ( i = 0 ; i < arr2 . length ; i ++ ) {
var arrSearchList1 = new Array ( ) ;
for ( j = 0 ; j < arr2 [ i ] . Count ( ) ; j ++ ) {
var strlSearchResult = arr2 [ i ] . QueryElementAt ( j , Components . interfaces . nsISupportsArray ) ;
var resultcount = strlSearchResult . Count ( ) ;
var arrDataPair = new Array ( ) ;
arrDataPair [ 0 ] = strlSearchResult . QueryElementAt ( 0 , Components . interfaces . nsISupportsPRInt32 ) ;
arrDataPair [ 1 ] = strlSearchResult . QueryElementAt ( 1 , Components . interfaces . nsISupportsCString ) ;
arrDataPair [ 2 ] = arr1 [ i ] ;
arrSearchList1 [ j ] = arrDataPair ;
}
arrFinalList [ i ] = arrSearchList1 ;
}
if ( context )
{
var row _count = context . getRowCount ( ) ;
var cmbSearchList = document . getElementById ( 'listSearchBox' ) ;
for ( i = 0 ; i < row _count ; i ++ )
{
context . removeItemAt ( 0 ) ;
}
for ( i = 0 ; i < arrFinalList . length ; i ++ )
{
for ( j = 0 ; j < arrFinalList [ i ] . length ; j ++ ) {
//creates the dynamic listbox which shows the searched records for the selected object in checkbox
var listcell = document . createElement ( "listcell" ) ;
var listItem = document . createElement ( "listitem" ) ;
var objectcharpref = getPref ( ) . getCharPref ( "object" ) . split ( ',' ) ;
var imagecharpref = getPref ( ) . getCharPref ( "imagename" ) . split ( ',' ) ;
var imagename = ''
for ( k = 0 ; k < objectcharpref . length ; k ++ ) {
if ( arr1 [ i ] == objectcharpref [ k ] ) {
imagename = imagecharpref [ k ]
}
}
listcell . setAttribute ( "image" , imagename ) ; // stores the image of the object
listcell . setAttribute ( "class" , "listcell-iconic" ) ;
listcell . setAttribute ( "width" , 12 ) ;
listcell . setAttribute ( "height" , 12 ) ;
listcell . setAttribute ( "label" , arrFinalList [ i ] [ j ] [ 1 ] ) ; //stores the name ofthe record
listItem . appendChild ( listcell ) ;
listItem . value = arrFinalList [ i ] [ j ] [ 0 ] ; //stores the id of the record
listItem . label = arr1 [ i ] ; // stores the value of the object
cmbSearchList . appendChild ( listItem ) ;
}
}
}
} ,
onFault : function ( client , ctxt , fault ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
} ,
onError : function ( client , ctxt , status , errorMsg ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
}
} ;
//function to search the records of selected checkbox object
function searchCheckbox ( )
{
var checkboxlist = getnamesearch ( ) ;
if ( checkboxlist . length == 0 ) {
alert ( "Select One or More Document" ) ;
return false ;
}
var branchobj = getPref ( ) ;
setServerService ( 'xmlrpc/object' ) ;
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
arrFinalList = [ ] ;
var xmlRpcClient = getXmlRpc ( ) ;
var end = document . getElementById ( 'listSearchBox' ) . getRowCount ( ) ;
for ( i = 0 ; i < end ; i ++ ) {
document . getElementById ( 'listSearchBox' ) . removeItemAt ( 0 ) ;
}
var cmbSearchList = document . getElementById ( 'listSearchBox' ) ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = branchobj . getCharPref ( "serverdbname" ) ;
var struid = xmlRpcClient . createType ( xmlRpcClient . INT , { } ) ;
struid . data = branchobj . getIntPref ( 'userid' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = branchobj . getCharPref ( "password" ) ;
var strmethod = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strmethod . data = 'search_checkbox' ;
var strname = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strname . data = document . getElementById ( 'txtvalueobj' ) . value ;
var strobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strobj . data = 'thunderbird.partner' ;
var arrofarr = dictcreation ( strname , checkboxlist ) ;
xmlRpcClient . asyncCall ( listSearchCheckboxHandler , cmbSearchList , 'execute' , [ strDbName , struid , strpass , strobj , strmethod , arrofarr ] , 6 ) ;
}
function searchContact ( )
{
var branchobj = getPref ( ) ;
setServerService ( 'xmlrpc/object' ) ;
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
arrFinalList = [ ] ;
var xmlRpcClient = getXmlRpc ( ) ;
var cmbSearchList = document . getElementById ( 'listSearchBox' ) ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = branchobj . getCharPref ( "serverdbname" ) ;
var struid = xmlRpcClient . createType ( xmlRpcClient . INT , { } ) ;
struid . data = branchobj . getIntPref ( 'userid' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = branchobj . getCharPref ( "password" ) ;
var strobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strobj . data = 'thunderbird.partner' ;
var strmethod = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strmethod . data = 'search_contact' ;
var strname = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strname . data = getSenderEmail ( ) ;
xmlRpcClient . asyncCall ( listSearchContactHandler , cmbSearchList , 'execute' , [ strDbName , struid , strpass , strobj , strmethod , strname ] , 6 ) ;
}
//xmlrpc request handler for getting the list of partners
var listPartnerHandler = {
onResult : function ( client , context , result ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var arrIdList = result . QueryInterface ( Components . interfaces . nsISupportsArray ) ;
2010-08-06 08:05:45 +00:00
// Set the number of results
2010-08-03 11:12:14 +00:00
var count = arrIdList . Count ( ) ;
// Loop through the results, adding items to the list
for ( i = 0 ; i < count ; i ++ ) {
var strlResult = arrIdList . QueryElementAt ( i , Components . interfaces . nsISupportsArray ) ;
var resultcount = strlResult . Count ( ) ;
var arrDataPair = new Array ( ) ;
arrDataPair [ 0 ] = strlResult . QueryElementAt ( 0 , Components . interfaces . nsISupportsPRInt32 ) ;
arrDataPair [ 1 ] = strlResult . QueryElementAt ( 1 , Components . interfaces . nsISupportsCString ) ;
arrPartnerList [ i ] = arrDataPair ;
}
if ( context )
{
var row _count = context . getRowCount ( ) ;
var cmdPartnerList = document . getElementById ( 'listPartnerBox' ) ;
for ( i = 0 ; i < row _count ; i ++ )
{
context . removeItemAt ( 0 ) ;
}
for ( i = 0 ; i < arrPartnerList . length ; i ++ )
{
var listcell = document . createElement ( "listcell" ) ;
var listItem = document . createElement ( "listitem" ) ;
listcell . setAttribute ( "label" , arrPartnerList [ i ] [ 1 ] ) ;
listItem . appendChild ( listcell ) ;
listItem . value = arrPartnerList [ i ] [ 0 ] ;
cmdPartnerList . appendChild ( listItem ) ;
}
}
} ,
onFault : function ( client , ctxt , fault ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
} ,
onError : function ( client , ctxt , status , errorMsg ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
}
2010-08-06 08:53:08 +00:00
}
2010-08-03 11:12:14 +00:00
//function to get the list of partners
function getPartnerList ( ) {
var branchobj = getPref ( ) ;
window . opener . document . getElementById ( 'txtselectpartner' ) . setAttribute ( 'value' , '' ) ;
setServerService ( 'xmlrpc/object' ) ;
var xmlRpcClient = getXmlRpc ( ) ;
arrPartnerList = [ ] ;
var end = document . getElementById ( 'listPartnerBox' ) . getRowCount ( ) ;
for ( i = 0 ; i < end ; i ++ ) {
document . getElementById ( 'listPartnerBox' ) . removeItemAt ( 0 ) ;
}
var cmdPartnerList = document . getElementById ( 'listPartnerBox' ) ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = branchobj . getCharPref ( "serverdbname" ) ;
var struid = xmlRpcClient . createType ( xmlRpcClient . INT , { } ) ;
struid . data = branchobj . getIntPref ( 'userid' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = branchobj . getCharPref ( "password" ) ;
var strmethod = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strmethod . data = 'name_search' ;
var strobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strobj . data = 'res.partner' ;
var strvalue = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strvalue . data = document . getElementById ( 'txtselectpartner' ) . value ;
xmlRpcClient . asyncCall ( listPartnerHandler , cmdPartnerList , 'execute' , [ strDbName , struid , strpass , strobj , strmethod , strvalue ] , 6 ) ;
}
//function to create the xmlrpc supported variables for xmlrpc request
function dictcontact ( a , b ) {
var temp = xmlRpcClient . createType ( xmlRpcClient . ARRAY , { } ) ;
for ( i = 0 ; i < a . length ; i ++ ) {
var strkey = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strkey . data = a [ i ]
var strvalue = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strvalue . data = b [ i ]
var test = xmlRpcClient . createType ( xmlRpcClient . ARRAY , { } ) ;
test . AppendElement ( strkey ) ;
test . AppendElement ( strvalue ) ;
temp . AppendElement ( test ) ;
}
return temp ;
}
//xmlrpc request handler for creating the record of mail
var listArchiveHandler = {
onResult : function ( client , context , result ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var createId = result . QueryInterface ( Components . interfaces . nsISupportsPRInt32 ) ;
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
//condition to handle the automatic attachment creation
attach = getAttachment ( )
attachment = "no"
2010-08-06 08:05:45 +00:00
var popup = document . getElementById ( "section" ) . selectedItem . value ; // a <menupopup> element
2010-08-03 11:12:14 +00:00
if ( getPref ( ) . getCharPref ( 'attachmentlength' ) > 0 ) {
if ( getAttachValue ( ) == '1' ) {
//calling the method to create the attachments
createAttachment ( popup , createId ) ;
attachment = "yes"
}
//condition to handle the manual attachment creation
if ( attach == "yes" ) {
//calling the method to create the attachments
createAttachment ( popup , createId ) ;
attachment = "yes"
}
else {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
attachment = "no"
}
}
else {
attachment = "no"
}
createAttachmentEML _CRM ( popup , createId , attachment )
} ,
onFault : function ( client , ctxt , fault ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
} ,
onError : function ( client , ctxt , status , errorMsg ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
}
2010-08-06 08:53:08 +00:00
}
2010-08-03 11:12:14 +00:00
//function to archive the mail content through xmlrpc request
function archivemail ( ) {
2010-08-06 08:05:45 +00:00
var popup = document . getElementById ( "section" ) . selectedItem ; // a <menupopup> element
2010-08-03 11:12:14 +00:00
if ( String ( popup ) != "null" ) {
object = popup . value ;
if ( object == undefined ) { alert ( "select At Least one Document !" ) }
else {
var branchobj = getPref ( ) ;
setServerService ( 'xmlrpc/object' ) ;
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var xmlRpcClient = getXmlRpc ( ) ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = branchobj . getCharPref ( "serverdbname" ) ;
var struids = xmlRpcClient . createType ( xmlRpcClient . INT , { } ) ;
struids . data = branchobj . getIntPref ( 'userid' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = branchobj . getCharPref ( "password" ) ;
var strmethod = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strmethod . data = 'mailcreate' ;
var strobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strobj . data = 'thunderbird.partner' ;
2010-08-04 09:05:15 +00:00
var a = [ 'name' , 'object' , 'date' , 'email_from' , 'email_cc' , 'description' , 'user_id' ] ;
var b = [ getSubject ( ) , object , getReceivedDate ( ) , getSenderEmail ( ) , getCCList ( ) , getMessageBody ( ) , branchobj . getIntPref ( 'userid' ) ] ;
2010-08-03 11:12:14 +00:00
var arrofarr = dictcontact ( a , b ) ;
xmlRpcClient . asyncCall ( listArchiveHandler , null , 'execute' , [ strDbName , struids , strpass , strobj , strmethod , arrofarr ] , 6 ) ;
}
}
else
{
alert ( " select At Least one Document !" )
}
}
//function to archive mail content after creating a new contact
function archivemail2contact ( ) {
var branchobj = getPref ( ) ;
setServerService ( 'xmlrpc/object' ) ;
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var xmlRpcClient = getXmlRpc ( ) ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = branchobj . getCharPref ( "serverdbname" ) ;
var struids = xmlRpcClient . createType ( xmlRpcClient . INT , { } ) ;
struids . data = branchobj . getIntPref ( 'userid' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = branchobj . getCharPref ( "password" ) ;
var strmethod = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strmethod . data = 'mailcreate' ;
var strobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strobj . data = 'thunderbird.partner' ;
var a = [ 'sender' , 'receiver' , 'date' , 'title' , 'reference' , 'res_user_id' , 'copy_to' , 'description' ] ;
var b = [ getSenderEmail ( ) , getReceiverEmail ( ) , getReceivedDate ( ) , getSubject ( ) , 'res.partner.address' + ',' + getContactId ( ) , branchobj . getIntPref ( 'userid' ) , getCCList ( ) , getMessageBody ( ) ] ;
var arrofarr = dictcontact ( a , b ) ;
xmlRpcClient . asyncCall ( listArchiveHandler , null , 'execute' , [ strDbName , struids , strpass , strobj , strmethod , arrofarr ] , 6 ) ;
}
//xmlrpc request handler for creating a new contact
var listCreateContactHandler = {
onResult : function ( client , context , result ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var createId = result . QueryInterface ( Components . interfaces . nsISupportsPRInt32 ) ;
setContactId ( createId ) ;
2010-08-04 09:05:15 +00:00
alert ( "Contact Created Successfully." ) ;
2010-08-03 11:12:14 +00:00
window . close ( ) ;
} ,
onFault : function ( client , ctxt , fault ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
} ,
onError : function ( client , ctxt , status , errorMsg ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
}
}
var listUpdateContactHandler = {
onResult : function ( client , context , result ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
2010-08-06 08:05:45 +00:00
var partnerId = result . QueryInterface ( Components . interfaces . nsISupportsPRInt32 ) ;
setResourceId ( partnerId ) ;
2010-08-03 11:12:14 +00:00
window . close ( ) ;
} ,
onFault : function ( client , ctxt , fault ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
} ,
onError : function ( client , ctxt , status , errorMsg ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
}
}
//function to create a new contact
function createContact ( ) {
var branchobj = getPref ( ) ;
setServerService ( 'xmlrpc/object' ) ;
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var xmlRpcClient = getXmlRpc ( ) ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = branchobj . getCharPref ( "serverdbname" ) ;
var struids = xmlRpcClient . createType ( xmlRpcClient . INT , { } ) ;
struids . data = branchobj . getIntPref ( 'userid' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = branchobj . getCharPref ( "password" ) ;
var strmethod = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strmethod . data = 'create_contact' ;
var strobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strobj . data = 'thunderbird.partner' ;
var a = [ 'partner_id' , 'name' , 'street' , 'street2' , 'zip' , 'city' , 'country_id' , 'state_id' , 'phone' , 'fax' , 'mobile' , 'email' ] ;
var b = [ getPartnerId ( ) , getSenderName ( ) , document . getElementById ( "txtstreet" ) . value , document . getElementById ( "txtstreet2" ) . value , document . getElementById ( "txtzip" ) . value , document . getElementById ( "txtcity" ) . value , document . getElementById ( "country" ) . value , document . getElementById ( "state" ) . value , document . getElementById ( "txtoffice" ) . value , document . getElementById ( "txtfax" ) . value , document . getElementById ( "txtmobile" ) . value , getSenderEmail ( ) ] ;
var arrofarr = dictcontact ( a , b ) ;
xmlRpcClient . asyncCall ( listCreateContactHandler , null , 'execute' , [ strDbName , struids , strpass , strobj , strmethod , arrofarr ] , 6 ) ;
}
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
function UpdateContact ( ) {
var branchobj = getPref ( ) ;
setServerService ( 'xmlrpc/object' ) ;
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var xmlRpcClient = getXmlRpc ( ) ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = branchobj . getCharPref ( "serverdbname" ) ;
var struids = xmlRpcClient . createType ( xmlRpcClient . INT , { } ) ;
struids . data = branchobj . getIntPref ( 'userid' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = branchobj . getCharPref ( "password" ) ;
var strmethod = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strmethod . data = 'update_contact' ;
var strobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strobj . data = 'thunderbird.partner' ;
2010-08-06 08:05:45 +00:00
var a = [ 'res_id' , 'partner_id' , 'name' , 'street' , 'street2' , 'zip' , 'city' , 'country_id' , 'state_id' , 'phone' , 'fax' , 'mobile' , 'email' ] ;
var b = [ getResourceId ( ) , getPartnerName ( ) , getSenderName ( ) , document . getElementById ( "txtstreet" ) . value , document . getElementById ( "txtstreet2" ) . value , document . getElementById ( "txtzip" ) . value , document . getElementById ( "txtcity" ) . value , document . getElementById ( "country" ) . value , document . getElementById ( "state" ) . value , document . getElementById ( "txtoffice" ) . value , document . getElementById ( "txtfax" ) . value , document . getElementById ( "txtmobile" ) . value , getSenderEmail ( ) ] ;
2010-08-03 11:12:14 +00:00
var arrofarr = dictcontact ( a , b ) ;
xmlRpcClient . asyncCall ( listUpdateContactHandler , null , 'execute' , [ strDbName , struids , strpass , strobj , strmethod , arrofarr ] , 6 ) ;
}
//xmlrpc request handler for creating a attachment record
var listAttachHandler = {
onResult : function ( client , context , result ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var createId = result . QueryInterface ( Components . interfaces . nsISupportsPRInt32 ) ;
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
} ,
onFault : function ( client , ctxt , fault ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
} ,
onError : function ( client , ctxt , status , errorMsg ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
}
}
//function to create a new attachment record
function createAttachment ( popup , res _id ) {
var branchobj = getPref ( ) ;
setServerService ( 'xmlrpc/object' ) ;
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var xmlRpcClient = getXmlRpc ( ) ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = branchobj . getCharPref ( "serverdbname" ) ;
var struids = xmlRpcClient . createType ( xmlRpcClient . INT , { } ) ;
struids . data = branchobj . getIntPref ( 'userid' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = branchobj . getCharPref ( "password" ) ;
var strmethod = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strmethod . data = 'create_attachment' ;
var strobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strobj . data = 'thunderbird.partner' ;
var resobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
object = popup ;
resobj . data = object ;
var a = [ 'name' , 'datas' , 'res_model' , 'res_id' , 'description' , 'datas_fname' ] ;
var b = [ getPref ( ) . getCharPref ( 'displayName' ) , getPref ( ) . getCharPref ( 'attachmentdata' ) , resobj , res _id , getSubject ( ) + '\n' + getSenderEmail ( ) , getPref ( ) . getCharPref ( 'displayName' ) ] ;
var arrofarr = dictcontact ( a , b ) ;
xmlRpcClient . asyncCall ( listAttachHandler , null , 'execute' , [ strDbName , struids , strpass , strobj , strmethod , arrofarr ] , 6 ) ;
}
//function to encode the string into base64
var base64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' . split ( "" ) ;
function base64 _encode ( s )
{
// the result/encrypted string, the padding string, and the pad count
var r = "" ; var p = "" ; var c = s . length % 3 ;
// add a right zero pad to make this string a multiple of 3 characters
if ( c > 0 ) { for ( ; c < 3 ; c ++ ) { p += '=' ; s += "\0" ; } }
// increment over the length of the string, three characters at a time
for ( c = 0 ; c < s . length ; c += 3 ) {
// we add newlines after every 76 output characters, according to the MIME specs
if ( c > 0 && ( c / 3 * 4 ) % 76 == 0 ) { r += "\r\n" ; }
// these three 8-bit (ASCII) characters become one 24-bit number
var n = ( s . charCodeAt ( c ) << 16 ) + ( s . charCodeAt ( c + 1 ) << 8 ) + s . charCodeAt ( c + 2 ) ;
// this 24-bit number gets separated into four 6-bit numbers
n = [ ( n >>> 18 ) & 63 , ( n >>> 12 ) & 63 , ( n >>> 6 ) & 63 , n & 63 ] ;
// those four 6-bit numbers are used as indices into the base64 character list
r += base64chars [ n [ 0 ] ] + base64chars [ n [ 1 ] ] + base64chars [ n [ 2 ] ] + base64chars [ n [ 3 ] ] ;
// add the actual padding string, after removing the zero pad
} return r . substring ( 0 , r . length - p . length ) + p ;
}
//function to encode the string into base64
var keyStr = "ABCDEFGHIJKLMNOP" +
"QRSTUVWXYZabcdef" +
"ghijklmnopqrstuv" +
"wxyz0123456789+/" +
"=" + "-_.!~*'()" ;
function encode64 ( input ) {
var output = "" ;
var chr1 , chr2 , chr3 = "" ;
var enc1 , enc2 , enc3 , enc4 = "" ;
var i = 0 ;
do {
chr1 = input . charCodeAt ( i ++ ) ;
chr2 = input . charCodeAt ( i ++ ) ;
chr3 = input . charCodeAt ( i ++ ) ;
enc1 = chr1 >> 2 ;
enc2 = ( ( chr1 & 3 ) << 4 ) | ( chr2 >> 4 ) ;
enc3 = ( ( chr2 & 15 ) << 2 ) | ( chr3 >> 6 ) ;
enc4 = chr3 & 63 ;
if ( isNaN ( chr2 ) ) {
enc3 = enc4 = 64 ;
} else if ( isNaN ( chr3 ) ) {
enc4 = 64 ;
}
output = output +
keyStr . charAt ( enc1 ) +
keyStr . charAt ( enc2 ) +
keyStr . charAt ( enc3 ) +
keyStr . charAt ( enc4 ) ;
chr1 = chr2 = chr3 = "" ;
enc1 = enc2 = enc3 = enc4 = "" ;
} while ( i < input . length ) ;
return output ;
}
//function to read the contents of the attachment files from the temp folder
function createInstance ( name , test ) {
var encoded _string = '' ;
var file _name = ''
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
for ( i = 0 ; i < test . length ; i ++ ) {
var stream = Components . classes [ "@mozilla.org/network/file-input-stream;1" ] . createInstance ( Components . interfaces . nsIFileInputStream ) ;
stream . init ( test [ i ] , 0x01 , 00004 , 0 ) ;
var bstream = Components . classes [ "@mozilla.org/binaryinputstream;1" ] . createInstance ( Components . interfaces . nsIBinaryInputStream ) ;
bstream . setInputStream ( stream ) ;
var r = new Array ( ) ;
var fileContents = bstream . readByteArray ( bstream . available ( ) , r ) ;
bstream . close ( ) ;
var printstring = '' ;
for ( j = 0 ; j < fileContents . length ; j ++ )
{
printstring += String . fromCharCode ( fileContents [ j ] ) ;
}
encoded _string += encode64 ( printstring ) + ',' ;
file _name += name [ i ] + ',' ;
test [ i ] . remove ( true ) ;
}
encoded _string = encoded _string . substring ( 0 , encoded _string . length - 1 ) ;
file _name = file _name . substring ( 0 , file _name . length - 1 ) ;
getPref ( ) . setCharPref ( 'displayName' , file _name ) ;
getPref ( ) . setCharPref ( 'attachmentdata' , encoded _string ) ;
}
//xmlrpc request handler for handling the login information
var listLoginHandler = {
onResult : function ( client , context , result ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var login = result . QueryInterface ( Components . interfaces . nsISupportsPrimitive )
if ( login . type == 12 ) {
login = result . QueryInterface ( Components . interfaces . nsISupportsPRInt32 )
setUserId ( login . data ) ;
alert ( 'Successful Login To OpenERP' ) ;
}
else {
alert ( "Login Failed" ) ;
}
} ,
onFault : function ( client , ctxt , fault ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
} ,
onError : function ( client , ctxt , status , errorMsg ) {
2010-08-06 08:53:08 +00:00
alert ( "Database does not Exist!\n\n Please specify proper database name." ) ;
2010-08-03 11:12:14 +00:00
}
}
//function to check the login information
function testConnection ( ) {
if ( getconnect _server ( ) == "false" )
{
alert ( "Please Login To The Database First !" )
return false ;
}
if ( getDBList ( ) == "false" )
{
if ( document . getElementById ( 'DBlist_text' ) . value == '' )
{
alert ( "You Must Enter Database Name" ) ;
return false ;
}
setDbName ( document . getElementById ( 'DBlist_text' ) . value ) ;
}
else
{
if ( document . getElementById ( 'DBlist' ) . value == 0 || document . getElementById ( 'DBlist' ) . value == "--select--" )
{
alert ( "You Must Select Database Name" ) ;
return false ;
}
setDbName ( document . getElementById ( 'DBlist' ) . value ) ;
}
var branchobj = getPref ( ) ;
setServer ( document . getElementById ( 'txturl' ) . value ) ;
var s = document . getElementById ( 'txturl' ) . value ;
var a = s . split ( ':' ) ;
setPort ( a [ a . length - 1 ] ) ;
setUsername ( document . getElementById ( 'txtusername' ) . value ) ;
setPassword ( document . getElementById ( 'txtpassword' ) . value ) ;
setServerService ( 'xmlrpc/common' ) ;
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var xmlRpcClient = getXmlRpc ( ) ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = getPref ( ) . getCharPref ( 'serverdbname' ) ;
var strusername = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strusername . data = getPref ( ) . getCharPref ( 'username' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = getPref ( ) . getCharPref ( 'password' ) ;
xmlRpcClient . asyncCall ( listLoginHandler , null , 'login' , [ strDbName , strusername , strpass ] , 3 ) ;
}
//xmlrpc request handler for handling the login information
var listcreateLoginHandler = {
onResult : function ( client , context , result ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var login = result . QueryInterface ( Components . interfaces . nsISupportsPrimitive )
setconnect _server ( "true" )
if ( login . type == 12 ) {
login = result . QueryInterface ( Components . interfaces . nsISupportsPRInt32 )
setUserId ( login . data ) ;
}
else {
alert ( "Login Failed" ) ;
}
} ,
onFault : function ( client , ctxt , fault ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
} ,
onError : function ( client , ctxt , status , errorMsg ) {
2010-08-06 08:05:45 +00:00
setconnect _server ( "false" )
2010-08-03 11:12:14 +00:00
}
}
//function to check the login information
function createConnection ( ) {
var branchobj = getPref ( ) ;
setServerService ( 'xmlrpc/common' ) ;
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var xmlRpcClient = getXmlRpc ( ) ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = getPref ( ) . getCharPref ( 'serverdbname' ) ;
var strusername = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strusername . data = getPref ( ) . getCharPref ( 'username' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = getPref ( ) . getCharPref ( 'password' ) ;
xmlRpcClient . asyncCall ( listcreateLoginHandler , null , 'login' , [ strDbName , strusername , strpass ] , 3 ) ;
}
//xmlrpc request handler for handling the partner information
var listCreatePartnerHandler = {
onResult : function ( client , context , result ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var createId = result . QueryInterface ( Components . interfaces . nsISupportsPRInt32 ) ;
if ( typeof ( createId . data ) == 'number' && createId != 0 ) {
window . close ( ) ;
}
if ( createId == 0 ) {
alert ( "Partner Already Exist" ) ;
}
} ,
onFault : function ( client , ctxt , fault ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
} ,
onError : function ( client , ctxt , status , errorMsg ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
}
}
//function to create the tiny partner object
function createPartner ( ) {
var branchobj = getPref ( ) ;
setServerService ( 'xmlrpc/object' ) ;
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var xmlRpcClient = getXmlRpc ( ) ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = branchobj . getCharPref ( "serverdbname" ) ;
var struids = xmlRpcClient . createType ( xmlRpcClient . INT , { } ) ;
struids . data = branchobj . getIntPref ( 'userid' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = branchobj . getCharPref ( "password" ) ;
var strmethod = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strmethod . data = 'create_partner' ;
var strobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strobj . data = 'thunderbird.partner' ;
if ( document . getElementById ( 'txtname' ) . value == '' ) {
alert ( "You Must Enter Partner Name" ) ;
return false ;
}
var a = [ 'name' ] ;
var b = [ document . getElementById ( 'txtname' ) . value ] ;
var arrofarr = dictcontact ( a , b ) ;
xmlRpcClient . asyncCall ( listCreatePartnerHandler , null , 'execute' , [ strDbName , struids , strpass , strobj , strmethod , arrofarr ] , 6 ) ;
}
//xmlrpc request handler for handling the object information
var listSearchDocumentHandler = {
onResult : function ( client , context , result ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var searchResult = result . QueryInterface ( Components . interfaces . nsISupportsPRInt32 ) ;
if ( searchResult . data == 0 ) {
alert ( "Document Does Not Exist" ) ;
return false ;
}
var objvalue = getPref ( ) . getCharPref ( "listobject" ) ;
var objectvalue = getPref ( ) . getCharPref ( "object" ) ;
var imagevalue = getPref ( ) . getCharPref ( "imagename" ) ;
var objcharpref = getPref ( ) . getCharPref ( "listobject" ) . split ( ',' ) ;
var objectcharpref = getPref ( ) . getCharPref ( "object" ) . split ( ',' ) ;
var imagecharpref = getPref ( ) . getCharPref ( "imagename" ) . split ( ',' ) ;
if ( objectcharpref . indexOf ( document . getElementById ( "txtobject" ) . value ) != - 1 ) {
alert ( "Document already in List" ) ;
}
else {
var listItem = document . createElement ( "listitem" ) ;
var listcell1 = document . createElement ( "listcell" ) ;
var listcell2 = document . createElement ( "listcell" ) ;
var listcell3 = document . createElement ( "listcell" ) ;
listcell1 . setAttribute ( "label" , document . getElementById ( "txtobj" ) . value ) ;
listcell2 . setAttribute ( "label" , document . getElementById ( "txtobject" ) . value ) ;
listcell3 . setAttribute ( "image" , 'file://' + document . getElementById ( "txtimagename" ) . value ) ;
listcell3 . setAttribute ( "class" , "listcell-iconic" )
listcell3 . setAttribute ( "width" , 16 )
listcell3 . setAttribute ( "height" , 16 )
listItem . appendChild ( listcell1 ) ;
listItem . appendChild ( listcell2 ) ;
listItem . appendChild ( listcell3 ) ;
document . getElementById ( "listObjectListBox" ) . appendChild ( listItem )
if ( getPref ( ) . getCharPref ( "object" ) != '' ) {
getPref ( ) . setCharPref ( "listobject" , objvalue + ',' + document . getElementById ( "txtobj" ) . value ) ;
getPref ( ) . setCharPref ( "object" , objectvalue + ',' + document . getElementById ( "txtobject" ) . value ) ;
getPref ( ) . setCharPref ( "imagename" , imagevalue + ',' + "file://" + document . getElementById ( "txtimagename" ) . value ) ;
}
else {
getPref ( ) . setCharPref ( "listobject" , document . getElementById ( "txtobj" ) . value ) ;
getPref ( ) . setCharPref ( "object" , document . getElementById ( "txtobject" ) . value ) ;
getPref ( ) . setCharPref ( "imagename" , "file://" + document . getElementById ( "txtimagename" ) . value ) ;
}
}
} ,
onFault : function ( client , ctxt , fault ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
} ,
onError : function ( client , ctxt , status , errorMsg ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
}
}
//function to search the tiny objects for configuration settings
function searchDocument ( ) {
var branchobj = getPref ( ) ;
setServerService ( 'xmlrpc/object' ) ;
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var xmlRpcClient = getXmlRpc ( ) ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = branchobj . getCharPref ( "serverdbname" ) ;
var struids = xmlRpcClient . createType ( xmlRpcClient . INT , { } ) ;
struids . data = branchobj . getIntPref ( 'userid' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = branchobj . getCharPref ( "password" ) ;
var strmethod = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strmethod . data = 'search_document' ;
var strobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strobj . data = 'thunderbird.partner' ;
if ( document . getElementById ( 'txtobj' ) . value == '' ) {
alert ( "You Must Enter Document" ) ;
return false ;
}
if ( document . getElementById ( 'txtobject' ) . value == '' ) {
alert ( "You Must Enter Document Name" ) ;
return false ;
}
var a = [ 'model' ] ;
var b = [ document . getElementById ( 'txtobject' ) . value ] ;
var arrofarr = dictcontact ( a , b ) ;
xmlRpcClient . asyncCall ( listSearchDocumentHandler , null , 'execute' , [ strDbName , struids , strpass , strobj , strmethod , arrofarr ] , 6 ) ;
}
//xmlrpc request handler for list of search object exist in database or not.
var listsearchAttachmentHandler = {
onResult : function ( client , context , result ) {
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var objectlist = result . QueryInterface ( Components . interfaces . nsISupportsCString ) ;
getPref ( ) . setCharPref ( 'tempobject' , objectlist )
document . getElementById ( "txtvalueobj" ) . value = getSenderEmail ( ) ;
var checkbox = document . getElementById ( "checkbox-dynamic" ) ;
var object = preferenceBranch . getCharPref ( "listobject" ) . split ( ',' ) ;
var obj = preferenceBranch . getCharPref ( "tempobject" ) . split ( ',' ) ;
var imagelist = preferenceBranch . getCharPref ( "imagename" ) . split ( ',' ) ;
count = 0
if ( object [ 0 ] != '' ) {
for ( var i = 0 ; i < object . length ; i ++ ) {
if ( obj [ i ] == "null" )
{
continue
}
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
if ( count % 3 == 0 ) {
var vbox = document . createElement ( "hbox" ) ;
}
count += 1
var hbox = document . createElement ( "vbox" ) ;
var checkbox1 = document . createElement ( "checkbox" ) ;
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
checkbox1 . setAttribute ( "label" , object [ i ] ) ;
checkbox1 . setAttribute ( "id" , "cbx" + ( i + 1 ) ) ;
checkbox1 . setAttribute ( "width" , 150 )
if ( obj [ i ] == "res.partner.address" )
{
checkbox1 . setAttribute ( "checked" , true ) ;
}
if ( i == 0 ) {
checkbox1 . setAttribute ( "checked" , true ) ;
}
var image1 = document . createElement ( "image" ) ;
image1 . setAttribute ( "src" , imagelist [ i ] ) ;
image1 . setAttribute ( "width" , 16 )
image1 . setAttribute ( "height" , 16 )
vbox . appendChild ( image1 ) ;
hbox . appendChild ( checkbox1 ) ;
vbox . appendChild ( hbox ) ;
checkbox . appendChild ( vbox ) ;
}
}
setTimeout ( "getAllDocument()" , 0 )
exis _grp = document . getElementById ( "existsobjectgroup" )
new _grp = document . getElementById ( "newobjectgroup" )
new _grp . height = parseInt ( parseInt ( new _grp . height ) + parseInt ( ( count / 3 ) * 23.5 ) )
win = document . getElementById ( "pluginwindows" ) . setAttribute ( "height" , 1000 )
} ,
onFault : function ( client , ctxt , fault ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
} ,
onError : function ( client , ctxt , status , errorMsg ) {
2010-08-06 08:53:08 +00:00
2010-08-03 11:12:14 +00:00
}
}
//function to create a new attachment record
function listSearchDocumentAttachment ( ) {
var branchobj = getPref ( ) ;
setServerService ( 'xmlrpc/object' ) ;
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var xmlRpcClient = getXmlRpc ( ) ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = branchobj . getCharPref ( "serverdbname" ) ;
var struids = xmlRpcClient . createType ( xmlRpcClient . INT , { } ) ;
struids . data = branchobj . getIntPref ( 'userid' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = branchobj . getCharPref ( "password" ) ;
var strmethod = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strmethod . data = 'search_document_attachment' ;
var strobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strobj . data = 'thunderbird.partner' ;
var resobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
2010-08-06 08:05:45 +00:00
var popup = document . getElementById ( "section" ) . selectedItem ; // a <menupopup> element
2010-08-03 11:12:14 +00:00
object = popup . value ;
resobj . data = object ;
var a = [ 'object' ] ;
var b = [ getPref ( ) . getCharPref ( "object" ) ] ;
var arrofarr = dictcontact ( a , b ) ;
xmlRpcClient . asyncCall ( listsearchAttachmentHandler , null , 'execute' , [ strDbName , struids , strpass , strobj , strmethod , arrofarr ] , 6 ) ;
}
//function to create a new attachment record
function createAttachmentEML ( )
{
if ( document . getElementById ( 'listSearchBox' ) . selectedItem )
{
data _attach = "no"
if ( getPref ( ) . getCharPref ( 'attachmentlength' ) > 0 && getAttachment ( ) == "yes" ) {
createAttachment ( document . getElementById ( 'listSearchBox' ) . selectedItem . label , document . getElementById ( 'listSearchBox' ) . selectedItem . value )
data _attach = "yes"
}
var fpath = ""
if ( navigator . userAgent . indexOf ( 'Linux' ) != - 1 ) {
fpath = "/tmp/"
}
else if ( navigator . userAgent . indexOf ( 'Win' ) != - 1 ) {
fpath = "C:\\"
}
else if ( navigator . userAgent . indexOf ( 'Mac OS X' ) != - 1 ) {
fpath = "/tmp/"
}
var encoded _string = ""
name = fpath + getFileName ( ) + ".eml"
var file = Components . classes [ "@mozilla.org/file/local;1" ] . createInstance ( Components . interfaces . nsILocalFile ) ;
file . initWithPath ( name ) ;
if ( file . exists ( ) == false ) {
return null ;
} else {
var is = Components . classes [ "@mozilla.org/network/file-input-stream;1" ] . createInstance ( Components . interfaces . nsIFileInputStream ) ;
is . init ( file , 0x01 , 00004 , null ) ;
var sis = Components . classes [ "@mozilla.org/scriptableinputstream;1" ] . createInstance ( Components . interfaces . nsIScriptableInputStream ) ;
sis . init ( is ) ;
var output = sis . read ( sis . available ( ) ) ;
encoded _string += encode64 ( output ) + ',' ;
encoded _string = encoded _string . substring ( 0 , encoded _string . length - 1 ) ;
a = ":"
if ( data _attach == "yes" )
{
alert ( "Mail Archived Successfully With Attachments" ) ;
window . close ( ) ;
}
else
{
alert ( "Mail Archived Successfully" + a ) ;
window . close ( ) ;
}
}
attach _eml = "yes" ;
var branchobj = getPref ( ) ;
setServerService ( 'xmlrpc/object' ) ;
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var xmlRpcClient = getXmlRpc ( ) ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = branchobj . getCharPref ( "serverdbname" ) ;
var struids = xmlRpcClient . createType ( xmlRpcClient . INT , { } ) ;
struids . data = branchobj . getIntPref ( 'userid' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = branchobj . getCharPref ( "password" ) ;
var strmethod = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strmethod . data = 'create_attachment' ;
var strobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strobj . data = 'thunderbird.partner' ;
var resobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
2010-08-06 08:05:45 +00:00
var popup = document . getElementById ( "section" ) . selectedItem ; // a <menupopup> element
2010-08-03 11:12:14 +00:00
object = popup . value ;
resobj . data = object ;
filename = getFileName ( )
if ( getFileName ( ) . length > 60 )
{
filename = filename . substring ( 0 , 60 ) ;
}
filename = filename + ".eml"
var a = [ 'name' , 'datas' , 'res_model' , 'description' , 'res_id' , 'datas_fname' ] ;
var b = [ getFileName ( ) , encoded _string , document . getElementById ( 'listSearchBox' ) . selectedItem . label , getSubject ( ) + '\n' + getSenderEmail ( ) , document . getElementById ( 'listSearchBox' ) . selectedItem . value , filename ] ;
var arrofarr = dictcontact ( a , b ) ;
xmlRpcClient . asyncCall ( listAttachHandler , null , 'execute' , [ strDbName , struids , strpass , strobj , strmethod , arrofarr ] , 6 ) ;
}
else
{
alert ( "you must select only one record" ) ;
}
}
//function to create a new attachment record
function createAttachmentEML _CRM ( model , id , attachment )
{
var fpath = ""
if ( navigator . userAgent . indexOf ( 'Linux' ) != - 1 ) {
fpath = "/tmp/"
}
else if ( navigator . userAgent . indexOf ( 'Win' ) != - 1 ) {
fpath = "C:\\"
}
else if ( navigator . userAgent . indexOf ( 'Mac OS X' ) != - 1 ) {
fpath = "/tmp/"
}
var encoded _string = ""
name = fpath + getFileName ( ) + ".eml"
var file = Components . classes [ "@mozilla.org/file/local;1" ] . createInstance ( Components . interfaces . nsILocalFile ) ;
file . initWithPath ( name ) ;
if ( file . exists ( ) == false ) {
return null ;
} else {
var is = Components . classes [ "@mozilla.org/network/file-input-stream;1" ] . createInstance ( Components . interfaces . nsIFileInputStream ) ;
is . init ( file , 0x01 , 00004 , null ) ;
var sis = Components . classes [ "@mozilla.org/scriptableinputstream;1" ] . createInstance ( Components . interfaces . nsIScriptableInputStream ) ;
sis . init ( is ) ;
var output = sis . read ( sis . available ( ) ) ;
encoded _string += encode64 ( output ) + ',' ;
encoded _string = encoded _string . substring ( 0 , encoded _string . length - 1 ) ;
a = ":"
}
if ( attachment == "yes" )
{
alert ( "Mail Archived Successfully With Attachments" ) ;
window . close ( ) ;
}
else
{
alert ( "Mail Archived Successfully" ) ;
window . close ( ) ;
}
attach _eml = "yes" ;
var branchobj = getPref ( ) ;
setServerService ( 'xmlrpc/object' ) ;
netscape . security . PrivilegeManager . enablePrivilege ( 'UniversalXPConnect UniversalBrowserAccess' ) ;
var xmlRpcClient = getXmlRpc ( ) ;
var strDbName = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strDbName . data = branchobj . getCharPref ( "serverdbname" ) ;
var struids = xmlRpcClient . createType ( xmlRpcClient . INT , { } ) ;
struids . data = branchobj . getIntPref ( 'userid' ) ;
var strpass = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strpass . data = branchobj . getCharPref ( "password" ) ;
var strmethod = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strmethod . data = 'create_attachment' ;
var strobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
strobj . data = 'thunderbird.partner' ;
var resobj = xmlRpcClient . createType ( xmlRpcClient . STRING , { } ) ;
filename = getFileName ( )
if ( getFileName ( ) . length > 60 )
{
filename = filename . substring ( 0 , 60 ) ;
}
filename = filename + ".eml"
var a = [ 'name' , 'datas' , 'res_model' , 'description' , 'res_id' , 'datas_fname' ] ;
var b = [ getFileName ( ) , encoded _string , model , getSubject ( ) + '\n' + getSenderEmail ( ) , id , filename ] ;
var arrofarr = dictcontact ( a , b ) ;
xmlRpcClient . asyncCall ( listAttachHandler , null , 'execute' , [ strDbName , struids , strpass , strobj , strmethod , arrofarr ] , 6 ) ;
}
function win _close ( )
{
var fpath = ""
if ( navigator . userAgent . indexOf ( 'Linux' ) != - 1 ) {
fpath = "/tmp/"
}
else if ( navigator . userAgent . indexOf ( 'Win' ) != - 1 ) {
fpath = "C:\\"
}
else if ( navigator . userAgent . indexOf ( 'Mac OS X' ) != - 1 ) {
fpath = "/tmp/"
}
try
{
name = fpath + getFileName ( ) + ".eml"
var file = Components . classes [ "@mozilla.org/file/local;1" ] . createInstance ( Components . interfaces . nsILocalFile ) ;
file . initWithPath ( name ) ;
file . remove ( true ) ;
window . close ( ) ;
}
catch ( err )
{
window . close ( ) ;
}
}
function attachmentWidnowOpen ( msg )
{
if ( getPref ( ) . getCharPref ( 'attachmentlength' ) > 0 )
{
if ( msg == "create" ) {
2010-08-06 08:05:45 +00:00
var popup = document . getElementById ( "section" ) . selectedItem ; // a <menupopup> element
2010-08-03 11:12:14 +00:00
if ( String ( popup ) != "null" ) {
object = popup . value ;
if ( object == "" || object == undefined ) { alert ( "select at least one Document !" ) }
else {
var answer = confirm ( "Mail Contain Attachment? \n\t Ok :- Create Document with attachments. \n\t Cancel :- Create Document Only(Attachment not attach)." )
if ( answer )
setAttachment ( 'yes' )
else
setAttachment ( 'no' )
archivemail ( )
}
}
else
{
alert ( "select Document !" )
}
}
else {
if ( document . getElementById ( 'listSearchBox' ) . selectedItem )
{
var answer = confirm ( "Mail Contain Attachment? \n\t Ok :- Attachments attach with selected record. \n\t Cancel :- Attachment not attach with selected record." )
if ( answer )
setAttachment ( 'yes' )
else
setAttachment ( 'no' )
createAttachmentEML ( )
}
else {
alert ( "you must select only one record" ) ;
}
}
}
else
{
if ( msg == "create" )
{
2010-08-06 08:05:45 +00:00
var popup = document . getElementById ( "section" ) . selectedItem ; // a <menupopup> element
2010-08-03 11:12:14 +00:00
if ( String ( popup ) != "null" ) {
object = popup . value ;
if ( object == "" || object == undefined ) { alert ( "select at least one document !" ) }
else {
archivemail ( )
}
}
else
{
alert ( "select at least one Document !" )
}
}
else if ( msg == "upload" )
{
if ( document . getElementById ( 'listSearchBox' ) . selectedItem )
{
createAttachmentEML ( )
}
else {
alert ( "you must select only one record" ) ;
}
}
}
}