Example #1
0
        private void connectToWebService()
        {
            if (ifWebService == null)
            {
                if (simiasRunning == false)
                {
                    Process[] processArray = Process.GetProcessesByName("simias");
                    if (processArray == null || processArray.Length == 0)
                    {
                        System.Diagnostics.Debug.WriteLine(string.Format("simias is not running dude..."));
                        return;
                    }
                    simiasRunning = true;
                }
                System.Diagnostics.Debug.WriteLine(string.Format("In connectToWebService(). Simias is running...", SimiasRunning));
                /// If simias is not started do not start the web services...
                //if (SimiasRunning == false)
                //    return;
                // Use the language stored in the registry.
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(GetLanguageDirectory());

                // Check if the iFolder Client is running.
                string windowName = resourceManager.GetString("iFolderServices") + Environment.UserName;
                Novell.Win32Util.Win32Window window = Novell.Win32Util.Win32Window.FindWindow(null, windowName);
                if (window != null)
                {
                    DateTime currentTime = DateTime.Now;
                    if ((currentTime.Ticks - ticks) > delta)
                    {
                        ticks = currentTime.Ticks;

                        // The registry holds the information needed to connect to the web service.
                        RegistryKey regKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Novell\iFolder");
                        if (regKey != null)
                        {
                            string webServiceUri  = regKey.GetValue("WebServiceUri") as string;
                            string simiasDataPath = regKey.GetValue("SimiasDataPath") as string;
                            if ((webServiceUri != null) && (simiasDataPath != null))
                            {
                                ifWebService     = new iFolderWebService();
                                ifWebService.Url = webServiceUri + "/iFolder.asmx";
                                LocalService.Start(ifWebService, new Uri(webServiceUri), simiasDataPath);

                                simws     = new SimiasWebService();
                                simws.Url = webServiceUri + "/Simias.asmx";
                                LocalService.Start(simws, new Uri(webServiceUri), simiasDataPath);
                            }

                            regKey.Close();
                        }
                    }
                }
                else
                {
                    throw new Exception("iFolder Client not running");
                }
            }
        }
Example #2
0
 public FormsTrayApp()
 {
     syncCollectionDelegate = new SyncCollectionDelegate(syncCollection);
        syncFileDelegate = new SyncFileDelegate(syncFile);
        createChangeEventDelegate = new CreateChangeEventDelegate(createChangeEvent);
        notifyMessageDelegate = new NotifyMessageDelegate(notifyMessage);
     appRestart = Novell.Win32Util.Win32Window.RegisterWindowMsg("AppCreated");
     RegistryKey regKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Novell\iFolder");
     string language = regKey.GetValue("language") as String;
     if (language != null)
     {
         try
         {
             Thread.CurrentThread.CurrentUICulture = new CultureInfo(language);
         }
         catch { }
     }
        string windowName = FormsTrayApp.resourceManager.GetString("iFolderServices") + Environment.UserName;
        Novell.Win32Util.Win32Window window = Novell.Win32Util.Win32Window.FindWindow(null, windowName);
        if (window != null)
        {
         Novell.Win32Util.Win32Window iFolderWindow = Novell.Win32Util.Win32Window.FindWindow(null, resourceManager.GetString("myiFolders"));
         if (iFolderWindow != null)
         {
             iFolderWindow.SendMsg(HWND_BOARDCAST, appRestart, IntPtr.Zero, IntPtr.Zero);
         }
     shutdown = true;
        }
        else
        {
     iFolderLogPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "iFolder");
     if (!Directory.Exists(iFolderLogPath))
     {
      Directory.CreateDirectory(iFolderLogPath);
     }
     this.simiasManager = new Manager( Environment.GetCommandLineArgs() );
     InitializeComponent();
     this.Text = FormsTrayApp.resourceManager.GetString("iFolderServices") + Environment.UserName;
     this.components = new System.ComponentModel.Container();
     this.ClientSize = new System.Drawing.Size(292, 266);
     try
     {
      string basePath = Path.Combine(Application.StartupPath, "res");
      startupIcon = new Icon(Path.Combine(basePath, "ifolder_waiting_16.ico"));
      shutdownIcon = new Icon(Path.Combine(basePath, "ifolder_download_16.ico"));
      trayIcon = new Icon(Path.Combine(basePath, "ifolder_16.ico"));
      syncIcons[0] = new Icon(trayIcon, trayIcon.Size);
      for (int i = 0; i < numberOfSyncIcons; i++)
      {
       string syncIcon = string.Format(Path.Combine(basePath, "ifolder_sync{0}.ico"), i+1);
       syncIcons[i] = new Icon(syncIcon);
      }
      this.ShowInTaskbar = false;
      this.WindowState = FormWindowState.Minimized;
      Win32Window win32Window = new Win32Window();
      win32Window.Handle = this.Handle;
      win32Window.MakeToolWindow();
      shellNotifyIcon = new ShellNotifyIcon(this.Handle);
      shellNotifyIcon.Text = resourceManager.GetString("iFolderServicesStarting");
      shellNotifyIcon.Icon = startupIcon;
      if( !iFolderComponent.DisplayTrayIconEnabled )
                   shellNotifyIcon.Visible = false;
      shellNotifyIcon.ContextMenu = contextMenu1;
      shellNotifyIcon.Click += new Novell.CustomUIControls.ShellNotifyIcon.ClickDelegate(shellNotifyIcon_Click);
      shellNotifyIcon.BalloonClick += new Novell.CustomUIControls.ShellNotifyIcon.BalloonClickDelegate(shellNotifyIcon_BalloonClick);
      shellNotifyIcon.ContextMenuPopup += new Novell.CustomUIControls.ShellNotifyIcon.ContextMenuPopupDelegate(shellNotifyIcon_ContextMenuPopup);
         }
     catch
     {
     }
     }
        this.Closing += new System.ComponentModel.CancelEventHandler(this.FormsTrayApp_Closing);
        this.Load += new System.EventHandler(FormsTrayApp_Load);
 }
Example #3
0
 public static Win32Window FindWindow(string className, string windowName)
 {
     IntPtr handle = FindWindowWin32(className, windowName);
        Win32Window win32Window = null;
        if (handle != IntPtr.Zero)
        {
     win32Window = new Win32Window();
     win32Window.Handle = handle;
        }
        return win32Window;
 }