Changed to MADDE; moved sb1 files to zouba.sb1 and made new zouba.madde for madde...
[ptas] / zouba / wrt / preview / script / lib / sapi / AppManager.js
diff --git a/zouba/wrt/preview/script/lib/sapi/AppManager.js b/zouba/wrt/preview/script/lib/sapi/AppManager.js
deleted file mode 100644 (file)
index 39682f2..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-/**\r
- * AppManager.js\r
- * \r
- * Nokia Web Runtime Service API emulation \r
- * WRT v1.1\r
- * \r
- * Copyright 2009 Nokia Corporation. All rights reserved.\r
-*/\r
-\r
\r
-(function(){\r
-       \r
-       var provider = 'Service.AppManager',\r
-               Interface = 'IAppManager';\r
-\r
-       /**\r
-        * AppManager service\r
-        */\r
-       var AppManagerService = function(){\r
-               this.GetList    = __GetList;\r
-               this.LaunchApp  = __LaunchApp;\r
-               this.LaunchDoc  = __LaunchDoc;\r
-               this.Cancel     = __Cancel;\r
-       }\r
-\r
-       device.implementation.extend(provider, Interface, new AppManagerService() );\r
-\r
-\r
-       /******************************************************/        \r
-       /******************************************************/        \r
-       /******************************************************/        \r
-\r
-       var     context = device.implementation.context,\r
-               _t = context._t,\r
-               method = '',\r
-               result = false,\r
-               DBase = null;\r
-       \r
-       /**\r
-        * AppManager: GetList\r
-        * @param {Object} criteria\r
-        */\r
-       function __GetList(criteria){\r
-               if ((result = validator.apply('GetList', arguments)) !== false)\r
-                       return result; \r
-\r
-               if (typeof criteria.Type == 'undefined') \r
-                       return error(device.implementation.ERR_MISSING_ARGUMENT, msg.missingType);\r
-\r
-               if (!/^(Application|UserInstalledPackage)$/i.test(criteria.Type)) \r
-                       return error(device.implementation.ERR_BAD_ARGUMENT_TYPE);\r
-               \r
-               // check if a callback was provided\r
-               if (arguments.length > 1)\r
-                       return error(device.implementation.ERR_SERVICE_NOT_SUPPORTED, msg.badAsync);\r
-               \r
-               var returnValue,\r
-                       filter = criteria.Filter || null;\r
\r
-               DBase = context.getData(provider);\r
-\r
-               if (criteria.Filter)\r
-                       context.notify(_t('%s:: GetList : filter not implemented in preview').arg(provider));\r
-\r
-               // Type = UserInstalledPackage\r
-               if (!/UserInstalledPackage/i.test(criteria.Type)){\r
-\r
-                       returnValue = context.Iterator( DBase[criteria.Type] || [] );\r
-\r
-               } else {\r
-               // Type = Application\r
-                       // @todo: apply filter criteria\r
-                       \r
-                       returnValue = context.Iterator( DBase[criteria.Type] || [] );\r
-               }\r
-\r
-               return context.Result(returnValue);\r
-       }\r
-                       \r
-       /**\r
-        * AppManager: LaunchApp\r
-        * @param {Object} criteria\r
-        * @param {function} callback function for async call (optional)\r
-        */\r
-       function __LaunchApp(criteria, callback){\r
-\r
-               if ((result = validator.apply('LaunchApp', arguments)) !== false)\r
-                       return result; \r
-               \r
-               if (typeof criteria.ApplicationID == 'undefined')\r
-                       return error(device.implementation.ERR_MISSING_ARGUMENT, msg.missingAppID);\r
-\r
-               // app id must be in the form "s60uid://<appid>" where <appid> is \r
-               // what is returned by GetList.\r
-               var appId = criteria.ApplicationID;\r
-               \r
-               if (!/^s60uid:\/\/0x/i.test(appId))\r
-                       return error(device.implementation.ERR_BAD_ARGUMENT_TYPE);\r
-       \r
-               if (criteria.CmdLind)\r
-                       context.notify(_t('%s:: LaunchApp : CmdLine not implemented in preview').arg(provider));\r
-\r
-               if (criteria.Options)\r
-                       context.notify(_t('%s:: LaunchApp : Options not implemented in preview').arg(provider));\r
-\r
-\r
-               if (typeof callback == 'function') {\r
-                       return context.callAsync(this, arguments.callee, criteria, callback);\r
-               }\r
-\r
-               appId = appId.replace(/^s60uid:\/\//i, '');     \r
-               DBase = context.getData(provider);\r
-\r
-               for(var type in DBase){\r
-                       for(var i in DBase[type]) {\r
-                               var item = DBase[type][i];\r
-                               if (item.Uid == appId) {\r
-                                       // found!\r
-                                       context.notify(_t('%s:: LaunchApp : application found & launched : id=%s').arg(provider, appId));\r
-                                       return context.ErrorResult(device.implementation.ERR_SUCCESS);\r
-                               }\r
-                       }\r
-               }\r
-               // if not found\r
-               return error(device.implementation.ERR_BAD_ARGUMENT_TYPE);\r
-       }\r
-                       \r
-       /**\r
-        * AppManager: LaunchDoc\r
-        * @param {Object} criteria\r
-        * @param {function} callback function for async call (optional)\r
-        */\r
-       function __LaunchDoc(criteria, callback){\r
-\r
-               if ((result = validator.apply('LaunchDoc', arguments)) !== false)\r
-                       return result; \r
-\r
-               if (typeof criteria.Document == 'undefined' && typeof criteria.MimeType == 'undefined')\r
-                       return error(device.implementation.ERR_MISSING_ARGUMENT, msg.missingDoc);\r
-\r
-               if (typeof criteria.Document != 'undefined' && !criteria.Document.DocumentPath)\r
-                       return error(device.implementation.ERR_BAD_ARGUMENT_TYPE);\r
-\r
-               if (criteria.Options)\r
-                       context.notify(_t('%s:: LaunchDoc : Options not implemented in preview').arg(provider));\r
-\r
-               if (typeof callback == 'function') {\r
-                       return context.callAsync(this, arguments.callee, criteria, callback);\r
-               }\r
-\r
-               // nothing to launch in emulation, just notify user\r
-               context.notify(_t('%s:: LaunchDoc : document launched').arg(provider));\r
-               \r
-               if (criteria.Document)\r
-                       // return success\r
-                       return context.ErrorResult(device.implementation.ERR_SUCCESS);\r
-               else\r
-                       // for mimetype, return value name of document\r
-                       return context.Result('', device.implementation.ERR_SUCCESS);\r
-       }\r
-\r
-       \r
-\r
-       /**\r
-        * AppManager: Cancel\r
-        * @param {Object} criteria\r
-        */\r
-       function __Cancel(criteria){\r
-               method = 'Cancel';\r
-               if (!criteria || !criteria.TransactionID)\r
-                       return error(device.implementation.ERR_MISSING_ARGUMENT, msg.missingTID);\r
-               \r
-               clearTimeout(criteria.TransactionID);\r
-               return context.ErrorResult(device.implementation.ERR_SUCCESS);\r
-       }\r
-\r
-\r
-       \r
-       /*******************************\r
-        * helper functions\r
-        *******************************/\r
-       \r
-       function error(code, msg /*, args...*/){\r
-\r
-               var args = ['AppManager',method].concat([].slice.call(arguments,2));\r
-               msg = msg ? _t().arg.apply(msg,args) : undefined;\r
-               return context.ErrorResult(code, msg);\r
-       }\r
-\r
-       /**\r
-        * validate common input arguments\r
-        * 'this' is string (object) name of calling function\r
-        * \r
-        * @param {arguments} arguments of calling function\r
-        * @return {Result} Result object if error, false if no error.\r
-        */\r
-       function validator() {\r
-               method = ''+this;\r
-               var     failed = false,\r
-                       criteria = arguments[0] || false;\r
-                       \r
-               if (!criteria || typeof criteria != 'object')\r
-                       return error(device.implementation.ERR_MISSING_ARGUMENT, msg.missingType);\r
-\r
-               return failed;\r
-       }\r
-\r
-       /** \r
-        * error messages\r
-        * order of %s args: Service name, method name, parameter name \r
-        */\r
-       var msg = {\r
-               missingType             : '%s:%s:Content Type Missing',\r
-               badAsync                : 'AppManger:GetList:Asynchronous version of API is not supported',     // typo on device!\r
-               missingAppID    : '%s:%s:Application ID  Missing',      // double space between ID & missing!!\r
-               missingDoc              : '%s:%s:Document/MimeType Missing/value more than expected length ',\r
-               missingTID              : '%s:Incorrect TransactionID',\r
-               is_invalid              : '%s:%s:%s is invalid'\r
-       };\r
-               \r
-\r
-}) ()\r
-\r