Adding new functionality. Can now request an app to be delivered to your system from a host server via XML-RPC. The app is passed via an associated array of [] = base64_encoded();. Using base64 to maintain binary file types (images/foreign lang files).

This commit is contained in:
skeeter 2002-02-20 03:46:27 +00:00
parent cbf5593ca0
commit 6697ac21b4
2 changed files with 133 additions and 85 deletions

View File

@ -33,6 +33,7 @@
'request_appbyid' => True, 'request_appbyid' => True,
'request_appbyname' => True, 'request_appbyname' => True,
'request_newer_applist' => True, 'request_newer_applist' => True,
'request_packaged_app' => True,
'get_appbyid' => True, 'get_appbyid' => True,
'get_appbyname' => True, 'get_appbyname' => True,
'find_new_app' => True 'find_new_app' => True
@ -45,6 +46,8 @@
var $client; var $client;
var $server; var $server;
var $dir_file = Array();
// var $target_page = '/cvsdemo/xmlrpc.php'; // var $target_page = '/cvsdemo/xmlrpc.php';
// var $target_site = 'www.phpgroupware.org'; // var $target_site = 'www.phpgroupware.org';
var $target_page = '/phpgroupware/xmlrpc.php'; var $target_page = '/phpgroupware/xmlrpc.php';
@ -125,6 +128,16 @@
) )
), ),
'docstring' => lang('compare an array of apps/versions against the repository and return new/updated list of apps.') 'docstring' => lang('compare an array of apps/versions against the repository and return new/updated list of apps.')
),
'package_app_byid' => Array(
'function' => 'package_app_byid',
'signature' => Array(
Array(
xmlrpcStruct,
xmlrpcString
)
),
'docstring' => lang('Package an application for transport back to the calling client.')
) )
); );
return $xml_functions; return $xml_functions;
@ -201,135 +214,157 @@
} }
} }
function request_packaged_app($app_id)
{
if(is_object($this->is))
{
return $this->is->send('system.package_app_byid',$app_id,$this->is->server['server_url']);
}
else
{
return $this->request('phpgwapi.app_registry.get_appbyname',$app_name);
}
}
function get_result() function get_result()
{ {
switch($this->db->num_rows()) switch($this->db->num_rows())
{ {
case 0: case 0:
$app[] = CreateObject('phpgwapi.xmlrpcval',CreateObject('phpgwapi.xmlrpcval',False,'boolean'),'boolean'); $app = False;
break;
case 1:
$this->db->next_record();
$app[] = CreateObject('phpgwapi.xmlrpcval',
Array(
'id' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_id'),'int'),
'name' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_name'),'string'),
'title' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_title'),'string'),
'version' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_version'),'string'),
'tables' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_tables'),'string')
),
'struct'
);
break; break;
default: default:
while($this->db->next_record()) while($this->db->next_record())
{ {
$app[] = CreateObject('phpgwapi.xmlrpcval', $app[$this->db->f('app_id')] = Array(
Array( 'id' => $this->db->f('app_id'),
'id' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_id'),'int'), 'name' => $this->db->f('app_name'),
'name' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_name'),'string'), 'title' => $this->db->f('app_title'),
'title' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_title'),'string'), 'version' => $this->db->f('app_version'),
'version' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_version'),'string'), 'tables' => $this->db->f('app_tables')
'tables' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_tables'),'string')
),
'struct'
); );
} }
break; break;
} }
return CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',$app, 'struct')); return $app;
} }
// function get_result() function xml_response($app)
// { {
// switch($this->db->num_rows()) switch(gettype($app))
// { {
// case 0: case 'boolean':
// $app = False; return CreateObject('phpgwapi.xmlrpcval',CreateObject('phpgwapi.xmlrpcval',False,'boolean'),'boolean');
// break; break;
// case 1: case 'array':
// $this->db->next_record(); @reset($app);
// $app = Array( while($app && list($id,$application) = each($app))
// 'id' => $this->db->f('app_id'), {
// 'name' => $this->db->f('app_name'), $updated_app[$id] = CreateObject('phpgwapi.xmlrpcval',
// 'title' => $this->db->f('app_title'), Array(
// 'version' => $this->db->f('app_version'), 'id' => CreateObject('phpgwapi.xmlrpcval',$id,'int'),
// 'tables' => $this->db->f('app_tables') 'name' => CreateObject('phpgwapi.xmlrpcval',$application['name'],'string'),
// ); 'title' => CreateObject('phpgwapi.xmlrpcval',$application['title'],'string'),
// break; 'version' => CreateObject('phpgwapi.xmlrpcval',$application['version'],'string'),
// default: 'tables' => CreateObject('phpgwapi.xmlrpcval',$application['tables'],'string')
// while($this->db->next_record()) ),
// { 'struct'
// $app[] = Array( );
// 'id' => $this->db->f('app_id'), }
// 'name' => $this->db->f('app_name'), return CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',$updated_app, 'struct'));
// 'title' => $this->db->f('app_title'), break;
// 'version' => $this->db->f('app_version'), }
// 'tables' => $this->db->f('app_tables') }
// );
// }
// break;
// }
// return $app;
// }
function get_appbyid($app_id) function get_appbyid($app_id)
{ {
$this->db->query('SELECT * FROM phpgw_applications WHERE app_id='.$app_id,__LINE__,__FILE__); $this->db->query('SELECT * FROM phpgw_applications WHERE app_id='.$app_id,__LINE__,__FILE__);
return $this->get_result(); return $this->xml_response($this->get_result());
} }
function get_appbyname($app_name) function get_appbyname($app_name)
{ {
$this->db->query("SELECT * FROM phpgw_applications WHERE app_name='".$app_name."'",__LINE__,__FILE__); $this->db->query("SELECT * FROM phpgw_applications WHERE app_name='".$app_name."'",__LINE__,__FILE__);
return $this->get_result(); return $this->xml_response($this->get_result());
} }
function get_allapps() function get_allapps()
{ {
$this->db->query('SELECT * FROM phpgw_applications',__LINE__,__FILE__); $this->db->query('SELECT * FROM phpgw_applications',__LINE__,__FILE__);
return $this->get_result(); return $this->xml_response($this->get_result());
} }
function find_new_app($apps) function find_new_app($apps)
{ {
$this->db->query('SELECT * FROM phpgw_applications',__LINE__,__FILE__); $this->db->query('SELECT * FROM phpgw_applications',__LINE__,__FILE__);
while($this->db->next_record()) $app = $this->get_result();
{
$app[$this->db->f('app_id')] = Array(
'id' => $this->db->f('app_id'),
'name' => $this->db->f('app_name'),
'title' => $this->db->f('app_title'),
'version' => $this->db->f('app_version'),
'tables' => $this->db->f('app_tables')
);
}
@reset($apps); @reset($apps);
while($apps && list($id,$application) = each($apps)) while($apps && list($id,$application) = each($apps))
{ {
if($app[$id]) if($app[$id])
{ {
if($app[$id]->version == $application->version) if($app[$id]['version'] == $application['version'])
{ {
unset($app[$id]); unset($app[$id]);
} }
} }
} }
@reset($app); return $this->xml_response($app);
while($app && list($id,$application) = each($app))
{
$updated_app[$id] = CreateObject('phpgwapi.xmlrpcval',
Array(
'id' => CreateObject('phpgwapi.xmlrpcval',$id,'int'),
'name' => CreateObject('phpgwapi.xmlrpcval',$application->name,'string'),
'title' => CreateObject('phpgwapi.xmlrpcval',$application->title,'string'),
'version' => CreateObject('phpgwapi.xmlrpcval',$application->version,'string'),
'tables' => CreateObject('phpgwapi.xmlrpcval',$application->tables,'string')
),
'struct'
);
}
return CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',$updated_app, 'struct'));
} }
function package_file($filename)
{
$fp=fopen($filename,'rt');
$packed_file = CreateObject('phpgwapi.xmlrpcval',fread($fp,filesize($filename)),'base64');
fclose($fp);
return $packed_file;
}
function pack_dir($directory,$app,$dir_prefix='')
{
$sep = filesystem_separator();
if($dir_prefix)
{
$dir_prefix .= $sep;
}
$d = dir($directory);
while($entry = $d->read())
{
$new_filename = $directory.$sep.$entry;
if(is_file($new_filename))
{
$this->dir_file[$dir_prefix.$entry] = $this->package_file($new_filename);
}
elseif(is_dir($new_filename))
{
if($entry != '.' && $entry != '..' && $entry != 'CVS')
{
// $this->dir_file[$dir_prefix.$entry] = CreateObject('phpgwapi.xmlrpcval',$new_filename,'string');
$dir_path[$dir_prefix.$entry] = $new_filename;
}
}
}
$d->close();
@reset($dir_path);
while($dir_path && list($dir_prefix,$filename) = each($dir_path))
{
$this->pack_dir($filename,$app,$dir_prefix);
}
}
function package_app_byid($appid)
{
$this->db->query('SELECT app_name FROM phpgw_applications WHERE app_id='.$appid,__LINE__,__FILE__);
if(!$this->db->num_rows())
{
return CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',False,'boolean'),'boolean');
}
$this->db->next_record();
$path_prefix = PHPGW_SERVER_ROOT.filesystem_separator().$this->db->f('app_name');
$this->dir_file = Array();
$this->pack_dir($path_prefix,$this->db->f('app_name'));
return CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',$this->dir_file,'struct'));
}
} }
?> ?>

View File

@ -709,6 +709,14 @@
return ExecMethod('phpgwapi.app_registry.find_new_app',$app->scalarval()); return ExecMethod('phpgwapi.app_registry.find_new_app',$app->scalarval());
} }
$GLOBALS['_xmlrpcs_package_app_byid_sig'] = array(array(xmlrpcStruct,xmlrpcString));
$GLOBALS['_xmlrpcs_package_app_byid_doc'] = 'Package an application for transport back to the calling client';
function _xmlrpcs_package_app_byid($server,$m)
{
$app = $m->getParam(0);
return ExecMethod('phpgwapi.app_registry.package_app_byid',$app->scalarval());
}
$GLOBALS['_xmlrpcs_login_sig'] = array(array(xmlrpcStruct,xmlrpcStruct)); $GLOBALS['_xmlrpcs_login_sig'] = array(array(xmlrpcStruct,xmlrpcStruct));
$GLOBALS['_xmlrpcs_login_doc'] = 'phpGroupWare client or server login via XML-RPC'; $GLOBALS['_xmlrpcs_login_doc'] = 'phpGroupWare client or server login via XML-RPC';
function _xmlrpcs_login($server,$m) function _xmlrpcs_login($server,$m)
@ -821,6 +829,11 @@
'signature' => $GLOBALS['_xmlrpcs_find_new_app_sig'], 'signature' => $GLOBALS['_xmlrpcs_find_new_app_sig'],
'docstring' => $GLOBALS['_xmlrpcs_find_new_app_doc'] 'docstring' => $GLOBALS['_xmlrpcs_find_new_app_doc']
), ),
'system.package_app_byid' => array(
'function' => '_xmlrpcs_package_app_byid',
'signature' => $GLOBALS['_xmlrpcs_package_app_byid_sig'],
'docstring' => $GLOBALS['_xmlrpcs_package_app_byid_doc']
),
'system.login' => array( 'system.login' => array(
'function' => '_xmlrpcs_login', 'function' => '_xmlrpcs_login',
'signature' => $GLOBALS['_xmlrpcs_login_sig'], 'signature' => $GLOBALS['_xmlrpcs_login_sig'],