Exemplo n.º 1
0
 public abstract bool Authenticate(WakeLock wakeLock);
Exemplo n.º 2
0
 public abstract void Connect(WakeLock wakeLock);
Exemplo n.º 3
0
 public override bool Authenticate(WakeLock wakeLock)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 4
0
 public override void Connect(WakeLock wakeLock)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
        private static void StartInternal(Service registeredService, WakeLock wakeLock)
        {
            if (IsManualSettingsNeeded(registeredService))
            {
                throw new ServiceSchedulerException("Service " + registeredService.Information.ServiceName + " needs manual input for settings.");
            }

            if (!IsRegistered(registeredService))
            {
                throw new ServiceSchedulerException("Could not locate service "
                                                    + registeredService.Information.ServiceName + ". Are you sure you registered it?");
            }

            if (IsRunning(registeredService))
            {
                throw new ServiceSchedulerException(registeredService.Information.ServiceName
                                                    + " service is already running.");
            }

            ClearFailures(registeredService);

            ServiceEvents.RaiseServiceSettingsLoaded(registeredService);

            Action connect = () =>
            {
                try
                {
                    registeredService.Connect(wakeLock);
                }
                catch (NotImplementedException)
                {
                }
                catch (ServiceSpecialRestartException)
                {
                    throw;
                }
                catch (ServiceExpiredException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    GetFlags(registeredService).ConnectionFailed = true;
                    throw new Exception("Service " + registeredService.Information.ServiceName
                                        + " flat out failed to connect. Problem: " + ex);
                }
            };

            Action authenticate = () =>
            {
                try
                {
                    var authSuccess = registeredService.Authenticate(wakeLock);

                    if (!authSuccess)
                    {
                        throw new Exception("Failed authentication "
                                            + registeredService.Information.ServiceName + ".");
                    }
                }
                catch (NotImplementedException)
                {
                }
                catch (ServiceSpecialRestartException)
                {
                    throw;
                }
                catch (ServiceExpiredException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    GetFlags(registeredService).AuthenticationFailed = true;
                    throw new Exception("Service " + registeredService.Information.ServiceName
                                        + " flat out failed to authenticate. Problem: " + ex);
                }
            };

            if (registeredService.Information.Procedure
                == ServiceInfo.ProcedureType.AuthenticateConnect)
            {
                authenticate();
                connect();
            }
            else if (registeredService.Information.Procedure
                     == ServiceInfo.ProcedureType.ConnectAuthenticate)
            {
                connect();
                authenticate();
            }

            GetFlags(registeredService).Running = true;
            ServiceEvents.RaiseServiceStarted(registeredService);
        }
Exemplo n.º 6
0
 public static void StartUnified(UnifiedService unifiedService, WakeLock wakeLock)
 {
     StartInternal(unifiedService, wakeLock);
 }
Exemplo n.º 7
0
 public TemporaryFree(WakeLock wakeLock)
 {
     _wakeLock = wakeLock;
     _wakeLock.TemporaryRelease();
 }
Exemplo n.º 8
0
 public void ScheduleWakeLock(WakeLock newWakeLock)
 {
     _wakeLockBalancer.ScheduleWakeLock(newWakeLock);
 }
Exemplo n.º 9
0
 public void RemoveWakeLock(WakeLock newWakeLock)
 {
     _wakeLockBalancer.RemoveWakeLock(newWakeLock);
 }