Beispiel #1
0
        private void PhotoServiceThread()
        {
            running = true;

            //Thread.Sleep (2000);
            while (running)
            {
                PhotoService.photoServiceEvent.WaitOne();
                if (running == false)
                {
                    continue;
                }

                ServiceInfo serviceInfo = null;
                //resetResolverEvent.Reset();

                lock (PhotoService.serviceLocker) {
                    if (PhotoService.outstanding.Count > 0)
                    {
                        serviceInfo = PhotoService.outstanding.Dequeue();
                    }
                }

                // if there was nothing to do, re-loop
                if (serviceInfo == null)
                {
                    continue;
                }

                Logger.Debug("Resolving photo for: {0}", serviceInfo.UserName);
                try {
                    if (serviceInfo.PhotoType.CompareTo(Preferences.Local) == 0)
                    {
                        SendingHandler.GetPhoto(serviceInfo);
                        serviceInfo.Photo = serviceInfo.Photo.ScaleSimple(48, 48, Gdk.InterpType.Bilinear);
                    }
                    else if (serviceInfo.PhotoType.CompareTo(Preferences.Gravatar) == 0)
                    {
                        string uri = Utilities.GetGravatarUri(serviceInfo.PhotoLocation);
                        serviceInfo.Photo = Utilities.GetPhotoFromUri(uri);
                        Logger.Debug("GetPhotoFromUri - finished");
                    }
                    else if (serviceInfo.PhotoType.CompareTo(Preferences.Uri) == 0)
                    {
                        serviceInfo.Photo = Utilities.GetPhotoFromUri(serviceInfo.PhotoLocation);
                        serviceInfo.Photo = serviceInfo.Photo.ScaleSimple(48, 48, Gdk.InterpType.Bilinear);
                    }
                    else
                    {
                        serviceInfo.Photo = Utilities.GetIcon("computer", 48);
                    }

                    // Call registered listeners
                    if (PhotoResolved != null)
                    {
                        PhotoResolved(serviceInfo);
                    }
                    else
                    {
                        Logger.Debug("No registered providers for PhotoResoved");
                    }
                } catch (Exception e) {
                    // FIXME:: Requeue and try again if the photo is
                    // coming from the network
                    Logger.Debug("Exception getting photo {0}", e);
                    //photoInfo.Photo = Utilities.GetIcon ("computer", 48);

                    // Failed to get the avatar requeue
                    lock (PhotoService.serviceLocker)
                        PhotoService.outstanding.Enqueue(serviceInfo);
                }
            }
        }
Beispiel #2
0
        private bool InitializeIdle()
        {
            requestHandler = new RequestHandler();
            sendingHandler = new SendingHandler();
            sendingHandler.Start();

            sendingHandler.TransferStarted     += TransferStartedHandler;
            sendingHandler.FileTransferStarted += FileTransferStartedHandler;
            sendingHandler.TransferProgress    += TransferProgressHandler;
            sendingHandler.TransferEnded       += TransferEndedHandler;

            try {
                photoService = new Giver.PhotoService();
                photoService.PhotoResolved += OnPhotoResolved;
                photoService.Start();
            } catch (Exception e) {
                Logger.Fatal("Failed to start the Photo Service");
                throw e;
            }


            try {
                locator = new ServiceLocator();
            } catch (Exception e) {
                if (e.Message.CompareTo("Daemon not running") == 0)
                {
                    Logger.Fatal("The Avahi Daemon is not running... start it before running Giver");
                }
                else
                {
                    Logger.Debug("Error starting ServiceLocator: {0}", e.Message);
                }

                throw e;
            }
            try {
                service = new GiverService();
            } catch (Exception e) {
                if (e.Message.CompareTo("Daemon not running") == 0)
                {
                    Logger.Fatal("The Avahi Daemon is not running... start it before running Giver");
                }
                else
                {
                    Logger.Debug("Error starting GiverService: {0}", e.Message);
                }

                throw e;
            }

            locator.ServiceRemoved  += OnServicesChanged;
            locator.ServiceAdded    += OnServicesChanged;
            service.ClientConnected += OnClientConnected;

            //tray = new NotificationArea("RtcApplication");
            SetupTrayIcon();

            if (!quiet)
            {
                TargetWindow.ShowWindow(locator);
            }

            return(false);
        }
Beispiel #3
0
		private bool InitializeIdle()
		{
			requestHandler = new RequestHandler();
			sendingHandler = new SendingHandler();
			sendingHandler.Start();

			sendingHandler.TransferStarted += TransferStartedHandler;
			sendingHandler.FileTransferStarted += FileTransferStartedHandler;
			sendingHandler.TransferProgress += TransferProgressHandler;
			sendingHandler.TransferEnded += TransferEndedHandler;

			try {
				photoService = new Giver.PhotoService ();
				photoService.PhotoResolved += OnPhotoResolved;
				photoService.Start ();
			} catch (Exception e) {
				Logger.Fatal ("Failed to start the Photo Service");
				throw e;
			}
			

			try {
				locator = new ServiceLocator();
			} catch (Exception e) {
				if(e.Message.CompareTo("Daemon not running") == 0) {
					Logger.Fatal("The Avahi Daemon is not running... start it before running Giver");
				}
				else
					Logger.Debug("Error starting ServiceLocator: {0}", e.Message);

				throw e;
			}
			try {
				service = new GiverService();
			} catch (Exception e) {
				if(e.Message.CompareTo("Daemon not running") == 0) {
					Logger.Fatal("The Avahi Daemon is not running... start it before running Giver");
				}
				else
					Logger.Debug("Error starting GiverService: {0}", e.Message);

				throw e;
			}

			locator.ServiceRemoved += OnServicesChanged;
			locator.ServiceAdded += OnServicesChanged;
			service.ClientConnected += OnClientConnected;

			//tray = new NotificationArea("RtcApplication");
			SetupTrayIcon();

			if (!quiet)
				TargetWindow.ShowWindow(locator);

			return false;
		}