Exemplo n.º 1
0
		/// <summary>
		/// Lists the installed modules.
		/// </summary>
		/// <returns>The installed modules.</returns>
		public override Module[] ListInstalledModules ()
		{
			List<Module> list = new List<Module> ();

			string ModulesPath = this.GetModulesRootPath();
			SystemLogger.Log(SystemLogger.Module.PLATFORM, "Listing installed modules under path: " + ModulesPath);

			DirectoryData modulesDirectory = new DirectoryData(ModulesPath);

			if(this.GetFileSystemService().ExistsDirectory(modulesDirectory)) {
				DirectoryData[] apps = this.GetFileSystemService().ListDirectories(modulesDirectory);
				foreach(DirectoryData app in apps) {
					SystemLogger.Log(SystemLogger.Module.PLATFORM, "directory: " + app.FullName);
					DirectoryData[] versions = this.GetFileSystemService().ListDirectories(app);

					foreach(DirectoryData version in versions) {
						SystemLogger.Log(SystemLogger.Module.PLATFORM, "version: " + version.FullName);
						Module module = new Module();
						module.Id = Path.GetFileName(app.FullName);
						module.Version = this.ParseModuleVersion(Path.GetFileName(version.FullName));
						list.Add(module);
					}
				}
			} else {
				SystemLogger.Log(SystemLogger.Module.PLATFORM, "Modules directory does not exists: " + ModulesPath);
			}

			return list.ToArray();
		}
Exemplo n.º 2
0
        /// <summary>
        /// Deletes the modules.
        /// </summary>
        /// <param name="modules">Modules.</param>
        public override void DeleteModules(Module[] modules)
        {
            List<Module> successlist = new List<Module> ();
            List<Module> failedlist = new List<Module> ();

            this.GetNotificationService().StartNotifyLoading(this.GetLocalizedMessage(DEFAULT_LOADING_MESSAGE_DELETE_MODULES));

            try {
                foreach(Module module in modules) {
                    bool moduleDeleted = false;
                    try {
                        string location = this.GetModuleLocation(module, false);
                        string directoryName = Path.Combine (this.GetFileSystemService().GetDirectoryRoot().FullName, location);
                        SystemLogger.Log(SystemLogger.Module.PLATFORM, "Deleting module under: " + location);

                        if(Directory.Exists(directoryName)) {
                            Directory.Delete(directoryName, true);
                            moduleDeleted = true;
                        } else {
                            SystemLogger.Log(SystemLogger.Module.PLATFORM, "Module does not exists on filesystem. It couldn't be deleted.");
                        }
                    } catch (Exception ex) {
                        SystemLogger.Log(SystemLogger.Module.PLATFORM,
                            "Exception when deleting module [" + (module!=null?module.Id:"undefined")+ "]: " + ex.Message);
                    }

                    if(moduleDeleted) {
                        successlist.Add(module);
                    } else {
                        failedlist.Add(module);
                    }
                }
            } catch (Exception ex) {
                SystemLogger.Log(SystemLogger.Module.PLATFORM, "Exception when deleting modules: " + ex.Message);
            }
            UIApplication.SharedApplication.InvokeOnMainThread (delegate {
                IPhoneUtils.GetInstance().FireUnityJavascriptEvent("Unity.AppLoader.onDeleteModulesFinished",
                                                                   new object []{successlist.ToArray(), failedlist.ToArray()});
            });

            this.GetNotificationService().StopNotifyLoading();
        }
Exemplo n.º 3
0
 public abstract Task DeleteModules(Module[] modules);
Exemplo n.º 4
0
        /// <summary>
        /// Updates the or install module.
        /// </summary>
        /// <param name="module">Module.</param>
        public virtual bool UpdateOrInstallModule(Module module)
        {
            IOService service = this.GetServiceFromUrl(module.LoadUrl);
            IORequest request = this.GetRequestWithRequiredHeaders ();

            String tempFile = this.GetIOService().InvokeServiceForBinary(request, service, "tmp.zip");

            if (tempFile!=null) {
                return this.StoreModuleZipFile(module, tempFile);
            } else {
                SystemLogger.Log(SystemLogger.Module.CORE, "It was not possible to get module data from url: " + module.LoadUrl);
            }

            return false;
        }
Exemplo n.º 5
0
 public abstract void UpdateModule(Module module, string callbackId);
Exemplo n.º 6
0
 public abstract bool StoreModuleZipFile(Module module, string tempFile);
Exemplo n.º 7
0
 public abstract void UpdateModule(Module module, string callbackId);
Exemplo n.º 8
0
 public abstract void DeleteModules(Module[] modules);
Exemplo n.º 9
0
 public abstract Task UpdateModule(Module module, string callbackId);
Exemplo n.º 10
0
		/// <summary>
		/// Stores the module zip file.
		/// </summary>
		/// <returns><c>true</c>, if module zip file was stored, <c>false</c> otherwise.</returns>
		/// <param name="module">Module.</param>
		/// <param name="tempFile">Temp file.</param>
		public override bool StoreModuleZipFile(Module module, string tempFile) {
			bool result = false;
			FileStream streamWriter = null;
			String fullTempFilePath = null;

			try {
				fullTempFilePath = Path.Combine(this.GetFileSystemService().GetDirectoryRoot ().FullName, tempFile);

				string location = this.GetModuleLocation(module, true);
				string moduleRootDir = module.Id + "-" + module.Version.ToString() + Path.DirectorySeparatorChar;
				string versionDirectory = Path.Combine (this.GetFileSystemService().GetDirectoryRoot().FullName, location);
				string appDirectory = Path.Combine (this.GetFileSystemService().GetDirectoryRoot().FullName, this.GetModuleLocation(module, false));
				SystemLogger.Log(SystemLogger.Module.PLATFORM, "Storing module to: " +location);

				if(!Directory.Exists(appDirectory)) {
					Directory.CreateDirectory(versionDirectory);
				} else {
					Directory.Delete(appDirectory, true);
					Directory.CreateDirectory(versionDirectory);
				}

				ZipFile zipFile = new ZipFile(fullTempFilePath);
				foreach(ZipEntry theEntry in zipFile) {
					// just for testing... 
					// SystemLogger.Log(SystemLogger.Module.PLATFORM, "Storing module entry name: " + theEntry.Name);
					string fileName = Path.GetFileName (theEntry.Name);
					if (fileName != String.Empty) {
						string fullPath = versionDirectory + "/" + theEntry.Name;
						
						if(theEntry.Name.IndexOf(moduleRootDir)==0) {
							fullPath = versionDirectory + "/" + theEntry.Name.Substring(moduleRootDir.Length);
						}
						
						fullPath = fullPath.Replace ("\\", "/");
						string fullDirPath = Path.GetDirectoryName (fullPath);
						if (!Directory.Exists (fullDirPath))
							Directory.CreateDirectory (fullDirPath);
						streamWriter = File.Create (fullPath);
						
						Stream entryStream = zipFile.GetInputStream(theEntry);
						byte[] data = IPhoneUtils.ConvertNonSeekableStreamToByteArray(entryStream);
						streamWriter.Write (data, 0, data.Length);
						
						streamWriter.Close ();
						streamWriter = null;
					}
				}
				result = true;

			} catch (Exception ex) {
				SystemLogger.Log(SystemLogger.Module.PLATFORM, "Exception when storing module: " + ex.Message, ex);
			} finally {
				if(streamWriter!=null)
					streamWriter.Close();

				if(fullTempFilePath!=null && File.Exists(fullTempFilePath)) {
					// deleting tempFile
					File.Delete(fullTempFilePath);
					SystemLogger.Log(SystemLogger.Module.PLATFORM, "tmp file deleted");
				}

			}
			return result;
		}
Exemplo n.º 11
0
		/// <summary>
		/// Loads the module.
		/// </summary>
		/// <param name="module">Module to be loaded.</param>
		/// <param name="moduleParams">Module parameters.</param>
		public override void LoadModule (Module module, ModuleParam[] moduleParams)
		{
			UIApplication.SharedApplication.InvokeOnMainThread (delegate { 

				try {
					if(module != null) {

						string location = this.GetModuleLocation(module, true);
						string directoryName = Path.Combine (this.GetFileSystemService().GetDirectoryRoot().FullName, location);

						/* TO BE REMOVED - 5.0.6 [AMOB-30]
						string path = Path.Combine (String.Format(DOCUMENTS_URI,IPhoneServiceLocator.CurrentDelegate.GetListeningPort()), location, DEFAULT_HOME_PAGE);
						*/
						string path = Path.Combine (DOCUMENTS_URI, location, DEFAULT_HOME_PAGE);

						if(Directory.Exists(directoryName)) {
							// pass parameters to the request URL
							if(moduleParams != null) {
								StringBuilder builder = new StringBuilder();
								int numParams = 0;
								foreach(ModuleParam p in moduleParams) {
									if(p.Name!=null && p.Name.Length>0 && p.Value!=null && p.Value.Length>0) {
										if(numParams==0) {
											builder.Append("?");
										} else {
											builder.Append("&");
										}
										builder.Append(p.Name+"="+p.Value);
										numParams++;
									}
								}
								path = path + builder.ToString();
							}

							SystemLogger.Log(SystemLogger.Module.PLATFORM, "Loading module at path: " + path);
							NSUrl nsUrl = new NSUrl(Uri.EscapeUriString(path));
							NSUrlRequest request = new NSUrlRequest (nsUrl, NSUrlRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData, 3600.0);

							IPhoneServiceLocator.CurrentDelegate.LoadRequest(request);
						} else {
							this.GetNotificationService().StartNotifyAlert(this.GetLocalizedMessage(DEFAULT_ALERT_MESSAGE_TITLE),  
							                                               this.GetLocalizedMessage(DEFAULT_ALERT_MESSAGE_LOAD_MODULE_ERROR), "OK");
						}
					} else {
								this.GetNotificationService().StartNotifyAlert(this.GetLocalizedMessage(DEFAULT_ALERT_MESSAGE_TITLE),  
						                                               this.GetLocalizedMessage(DEFAULT_ALERT_MESSAGE_LOAD_MODULE_ERROR), "OK");
					}
				} catch (Exception ex) {
					SystemLogger.Log(SystemLogger.Module.PLATFORM, "Exception when loading module: " + ex.Message);
				}
			});
		}
Exemplo n.º 12
0
		/// <summary>
		/// Loads the module (try to update it first if 'autUpdate' argument is set to true). Update is "silent", no event listener is called.
		/// </summary>
		/// <param name="module">Module to be loaded.</param>
		/// <param name="moduleParams">Module parameters.</param>
		/// <param name="autoUpdate">True to first update the module, prior to be loaded. False is the default value.</param>
		public override void LoadModule (Module module, ModuleParam[] moduleParams, bool autoUpdate)
		{
			if(autoUpdate) {
				// show activity indicator
				this.GetNotificationService().StartNotifyActivity();
				this.GetNotificationService().StartNotifyLoading(this.GetLocalizedMessage(DEFAULT_LOADING_MESSAGE_UPDATE_MODULE));
				
				if(module != null) {
					bool success = this.UpdateOrInstallModule(module);
					if(success) {
						SystemLogger.Log(SystemLogger.Module.PLATFORM, "[LoadModule#autoUpdate] The module [ " +  module.Id + "] was successfully updated");
					} else {
						SystemLogger.Log(SystemLogger.Module.PLATFORM, "[LoadModule#autoUpdate] The module [ " +  module.Id + "] was NOT successfully updated");
					}
				}
				
				// hide activity indicator
				this.GetNotificationService().StopNotifyActivity();
				this.GetNotificationService().StopNotifyLoading();
			}

			// Load the just updated (or not) module.
			this.LoadModule(module, moduleParams);
		}
Exemplo n.º 13
0
 public abstract void LoadModule(Module module, ModuleParam[] moduleParams, bool autoUpdate);
Exemplo n.º 14
0
 public abstract void LoadModule(Module module, ModuleParam[] moduleParams);
Exemplo n.º 15
0
 public abstract Task LoadModule(Module module, ModuleParam[] moduleParams);
Exemplo n.º 16
0
 public abstract Task LoadModule(Module module, ModuleParam[] moduleParams, bool autoUpdate);
Exemplo n.º 17
0
		/// <summary>
		/// Updates the modules.
		/// </summary>
		/// <param name="modules">Modules.</param>
		/// <param name="callbackId">An identifier to be returned on the event listener in order to identify this request.</param>
		public override void UpdateModules (Module[] modules, string callbackId)
		{
			List<Module> successlist = new List<Module> ();
			List<Module> failedlist = new List<Module> ();
			
			// show activity indicator
			this.GetNotificationService().StartNotifyActivity();
			this.GetNotificationService().StartNotifyLoading(this.GetLocalizedMessage(DEFAULT_LOADING_MESSAGE_UPDATE_MODULES));

			foreach(Module module in modules) {
				bool success = this.UpdateOrInstallModule(module);
				if(success) {
					SystemLogger.Log(SystemLogger.Module.PLATFORM, "The module [ " +  module.Id + "] was successfully updated");
					successlist.Add(module);
				} else {
					SystemLogger.Log(SystemLogger.Module.PLATFORM, "The module [ " +  module.Id + "] was NOT successfully updated");
					failedlist.Add (module);
				}
			}

			UIApplication.SharedApplication.InvokeOnMainThread (delegate {
				IPhoneUtils.GetInstance().FireUnityJavascriptEvent("Appverse.AppLoader.onUpdateModulesFinished", 
				                                                   new object []{successlist.ToArray(), failedlist.ToArray(), callbackId});
			});

			// hide activity indicator
			this.GetNotificationService().StopNotifyActivity();
			this.GetNotificationService().StopNotifyLoading();
		}
Exemplo n.º 18
0
 public abstract Task UpdateModules(Module[] modules, string callbackId);
Exemplo n.º 19
0
 public abstract void LoadModule(Module module, ModuleParam[] moduleParams);
Exemplo n.º 20
0
 /// <summary>
 /// Gets the module location.
 /// </summary>
 /// <returns>The module location.</returns>
 /// <param name="module">Module.</param>
 /// <param name="versioned">True to return location including version folder, False to return just the module location (for deleting tasks).</param>
 public virtual string GetModuleLocation(Module module, bool versioned)
 {
     if(module!=null) {
         if(versioned)
             return Path.Combine(this.GetModulesRootPath(), Path.Combine(module.Id, module.Version.ToString()));
         else
             return Path.Combine(this.GetModulesRootPath(), module.Id);
     }
     return "";
 }
Exemplo n.º 21
0
 public abstract bool StoreModuleZipFile(Module module, string tempFile);