public OAuthClientHandlerService()
     : base()
 {
     appContext = Application.Context;
     tcs        = new TaskCompletionSource <OAuthResult> ();
     logger     = ServiceFinder.Resolve <ILogService> ();
 }
        public override void OnTokenRefresh()
        {
            if (ServiceFinder.IsRegistered <IPush>())
            {
                var push   = ServiceFinder.Resolve <IPush>() as Push;
                var config = ServiceFinder.Resolve <IDeviceService>().ReadPushConfig();

                push.Registration.UpdateConfig(config);
            }
        }
Exemplo n.º 3
0
 public AppProps ReadAppProps()
 {
     if (null == appPropsObj)
     {
         Properties  appProps           = new Properties();
         Stream      input              = null;
         ILogService logger             = ServiceFinder.Resolve <ILogService>();
         bool        foundLocalDevProps = false;
         try {
             try
             {
                 input = Application.Context.Assets.Open(LOCAL_DEV_APP_PROP_FILE);
                 foundLocalDevProps = true;
             }
             catch (Exception ex)
             {
                 input = null;
                 foundLocalDevProps = false;
                 input = Application.Context.Assets.Open(APP_PROP_FILE);
             }
             appProps.Load(input);
             appPropsObj               = new AppProps();
             appPropsObj.projectid     = appProps.GetProperty(PROJECT_ID_PROP);
             appPropsObj.appid         = appProps.GetProperty(APP_ID_PROP);
             appPropsObj.appkey        = appProps.GetProperty(APP_KEY_PROP);
             appPropsObj.host          = appProps.GetProperty(HOST_PROP);
             appPropsObj.connectiontag = appProps.GetProperty(CONNECTION_TAG_PROP);
             appPropsObj.mode          = appProps.GetProperty(MODE_PROP);
             if (foundLocalDevProps)
             {
                 appPropsObj.IsLocalDevelopment = true;
             }
             return(appPropsObj);
         } catch (Exception ex) {
             if (null != logger)
             {
                 logger.e(TAG, "Failed to load " + APP_PROP_FILE, ex);
             }
             return(null);
         } finally {
             if (null != input)
             {
                 try {
                     input.Close();
                 } catch (Exception exc) {
                     if (null != logger)
                     {
                         logger.w(TAG, "Failed to close stream", exc);
                     }
                 }
             }
         }
     }
     return(appPropsObj);
 }
Exemplo n.º 4
0
        public AppProps ReadAppProps()
        {
            if (null != _appPropsObj)
            {
                return(_appPropsObj);
            }
            var    appProps = new Properties();
            Stream input    = null;
            var    logger   = ServiceFinder.Resolve <ILogService>();

            try
            {
                bool foundLocalDevProps;
                try
                {
                    input = Application.Context.Assets.Open(LocalDevAppPropFile);
                    foundLocalDevProps = true;
                }
                catch (Exception)
                {
                    input = null;
                    foundLocalDevProps = false;
                    input = Application.Context.Assets.Open(AppPropFile);
                }
                appProps.Load(input);
                _appPropsObj = new AppProps
                {
                    projectid     = appProps.GetProperty(ProjectIdProp),
                    appid         = appProps.GetProperty(AppIdProp),
                    appkey        = appProps.GetProperty(AppKeyProp),
                    host          = appProps.GetProperty(HostProp),
                    connectiontag = appProps.GetProperty(ConnectionTagProp),
                    mode          = appProps.GetProperty(ModeProp)
                };
                if (foundLocalDevProps)
                {
                    _appPropsObj.IsLocalDevelopment = true;
                }
                return(_appPropsObj);
            }
            catch (Exception ex)
            {
                logger?.e(Tag, "Failed to load " + AppPropFile, ex);
                return(null);
            }
            finally
            {
                input?.Dispose();
            }
        }
Exemplo n.º 5
0
        public override async void OnMessageReceived(string from, Bundle data)
        {
            if (!ServiceFinder.IsRegistered <IPush>())
            {
                await FHClient.Init();

                FH.RegisterPush(DefaultHandleEvent);
            }

            var push        = ServiceFinder.Resolve <IPush>() as Push;
            var message     = data.GetString("alert");
            var messageData = data.KeySet().ToDictionary(key => key, key => data.GetString(key));

            (push.Registration as GcmRegistration).OnPushNotification(message, messageData);
        }
Exemplo n.º 6
0
        public PushConfig ReadPushConfig()
        {
            var    appProps = new Properties();
            Stream input    = null;
            var    logger   = ServiceFinder.Resolve <ILogService>();

            try
            {
                input = Application.Context.Assets.Open(AppPropFile);
                appProps.Load(input);

                var pushServerUrl = appProps.GetProperty(HostProp) + "/api/v2/ag-push/";
                var pushSenderId  = appProps.GetProperty("PUSH_SENDER_ID");
                var pushVariant   = appProps.GetProperty("PUSH_VARIANT");
                var pushSecret    = appProps.GetProperty("PUSH_SECRET");

                if (appProps.GetProperty(HostProp) != null && pushSenderId != null && pushVariant != null && pushSecret != null)
                {
                    return new AndroidPushConfig
                           {
                               UnifiedPushUri = new Uri(pushServerUrl),
                               SenderId       = pushSenderId,
                               VariantId      = pushVariant,
                               VariantSecret  = pushSecret
                           }
                }
                ;
                var ex =
                    new InvalidOperationException(
                        "fhconfig.properties must define PUSH_SERVER_URL, PUSH_SENDER_ID, PUSH_VARIANT, and PUSH_SECRET.  One or more were not defined.");
                logger.e(Tag,
                         "fhconfig.properties must define PUSH_SERVER_URL, PUSH_SENDER_ID, PUSH_VARIANT, and PUSH_SECRET.  One or more were not defined.",
                         ex);
                throw ex;
            }
            catch (Exception ex)
            {
                logger?.e(Tag, "Failed to load " + AppPropFile, ex);
                return(null);
            }
            finally
            {
                input?.Dispose();
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="aContext">application context</param>
 /// <param name="aSettings">setting</param>
 public FHOAuthWebview(Activity aContext, Bundle aSettings)
 {
     this.context     = aContext;
     this.webSettings = aSettings;
     this.logger      = ServiceFinder.Resolve <ILogService> ();
 }
Exemplo n.º 8
0
 public DeviceService()
 {
     logger = ServiceFinder.Resolve <ILogService> ();
 }
Exemplo n.º 9
0
 public override Task <PushConfig> LoadConfigJson(string filename)
 {
     return(Task.Run(() => ServiceFinder.Resolve <IDeviceService>().ReadPushConfig()));
 }