Represents command execution result
Inheritance: System.EventArgs
Esempio n. 1
0
 public void close(string options = "")
 {
     if (browser != null)
     {
         Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
             if (frame != null)
             {
                 PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
                 if (page != null)
                 {
                     Grid grid = page.FindName("LayoutRoot") as Grid;
                     if (grid != null)
                     {
                         grid.Children.Remove(browser);
                     }
                     page.ApplicationBar = null;
                 }
             }
             browser = null;
             string message = "{\"type\":\"exit\"}";
             PluginResult result = new PluginResult(PluginResult.Status.OK, message);
             result.KeepCallback = false;
             this.DispatchCommandResult(result);
         });
     }
 }
Esempio n. 2
0
    public async void readSecret(string ignored)
    {
        var token = await new Repository().ReadToken();

        PluginResult result = new PluginResult(PluginResult.Status.OK, token);
        DispatchCommandResult(result);
    }
Esempio n. 3
0
 public void greet(string args)
 {
     string name = JsonHelper.Deserialize<string[]>(args)[0];
     string message = "Hello " + name;
     PluginResult result = new PluginResult(PluginResult.Status.OK, message);
     DispatchCommandResult(result);
 }
    void HandleNotification(Event pushEvent)
    {
        PluginResult result = new PluginResult(PluginResult.Status.OK, pushEvent);
        result.KeepCallback = true;
        DispatchCommandResult(result);

    }
Esempio n. 5
0
        public void init(string args)
        {
            var pr = new PluginResult(PluginResult.Status.OK);
            pr.KeepCallback = true;

            try
            {
                if (string.IsNullOrEmpty(args))
                {
                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "You must supply Facebook Application Key"));
                    return;
                }

                var _args = WPCordovaClassLib.Cordova.JSON.JsonHelper.Deserialize<string[]>(args);
                FacebookSessionClient = new FacebookSessionClient(_args[0]);

                DateTime access_expires;

                Settings.TryGetValue<string>("fb_access_token", out AccessToken);
                Settings.TryGetValue<DateTime>("fb_access_expires", out  access_expires);

                if (AccessToken != null)
                    this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
                else
                    DispatchCommandResult(new PluginResult(PluginResult.Status.NO_RESULT));
            }
            catch (Exception ex)
            {
                RemoveLocalData();
                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ex.Message));
            }
        }
Esempio n. 6
0
 public void registerWPEventDispatcher(string parameters)
 {
     this.eventDispatcherCallbackId = this.CurrentCommandCallbackId;
     PluginResult result = new PluginResult(PluginResult.Status.OK);
     result.KeepCallback = true;
     DispatchCommandResult(result, this.eventDispatcherCallbackId);
 }
        void getMeanings(object sender, DefineCompletedEventArgs e)
        {
            //System.Diagnostics.Debug.WriteLine(e.Result.ToString());

            try
            {
                List<Definition> defList = e.Result.Definitions.ToList();
                List<string> definitions = new List<string>();
                
                //string jsonArray = JsonConvert.SerializeObject(defList, Formatting.Indented);
                Dictionary<string, List<Definition>> obj = new Dictionary<string, List<Definition>>();
                obj.Add("Definitions", defList);
                Dictionary<string, Dictionary<string, List<Definition>>> jsonDic = new Dictionary<string, Dictionary<string, List<Definition>>>();
                jsonDic.Add("DATA", obj);
                string jsonObj = JsonConvert.SerializeObject(jsonDic, Formatting.Indented);
                System.Diagnostics.Debug.WriteLine(jsonObj);
                PluginResult result = new PluginResult(PluginResult.Status.OK,jsonObj);
                result.KeepCallback=false;
                DispatchCommandResult(result);
            }
            catch (Exception ex)
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Service Error: Did not get proper response from the server, Please check network connectivity"));
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
        }
Esempio n. 8
0
 /// <summary>
 /// 安装成功回调
 /// </summary>
 /// <param name="type">类型标识:安装/卸载</param>
 /// <param name="appId">应用id</param>
 public override void OnSuccess(AMS_OPERATION_TYPE type, String appId)
 {
     string res = String.Format("\"appid\":\"{0}\",\"type\":\"{1}\"", appId, ((int)type).ToString());
     res = "{" + res + "}";
     xFaceLib.Log.XLog.WriteInfo("--------------AMS OnSuccess result: " + res);
     PluginResult result = new PluginResult(PluginResult.Status.OK, res);
     DispatchPluginResult(this, result);
 }
        public void getInstallationObjectId(string args)
        {

            String objectId = ParseInstallation.CurrentInstallation.ObjectId.ToString();
            var result = new PluginResult(PluginResult.Status.OK, objectId);
            DispatchCommandResult(result);

        }
Esempio n. 10
0
 /// <summary>
 /// 安装错误回调
 /// </summary>
 /// <param name="type">类型标识:安装/卸载</param>
 /// <param name="appId">应用id</param>
 /// /// <param name="errorState">错误码</param>
 public override void OnError(AMS_OPERATION_TYPE type, String appId, AMS_ERROR errorState)
 {
     string res = String.Format("\"errorcode\":\"{0}\",\"appid\":\"{1}\",\"type\":\"{2}\"",
         ((int)errorState).ToString(), appId, ((int)type).ToString());
     res = "{" + res + "}";
     xFaceLib.Log.XLog.WriteInfo("-------------------AMS OnError result: " + res);
     PluginResult result = new PluginResult(PluginResult.Status.ERROR, res);
     DispatchPluginResult(this, result);
 }
Esempio n. 11
0
    public void generateOTP(string unparsed)
    {
        var secret = JsonHelper.Deserialize<string[]>(unparsed)[0];

        Totp generator = new Totp(secret);

        PluginResult result = new PluginResult(PluginResult.Status.OK, generator.now());
        DispatchCommandResult(result);
    }
        /// <summary>
        /// Native implementation for "authenticate" action
        /// </summary>
        public void authenticate(object jsVersion)
        {
            PhoneHybridMainPage.GetInstance().Authenticate(this);

            // Done
            PluginResult noop = new PluginResult(PluginResult.Status.NO_RESULT);
            noop.KeepCallback = true;
            DispatchCommandResult(noop);
        }
        public void getSubscriptions(string args)
        {


            var installation = ParseInstallation.CurrentInstallation;
            IEnumerable<string> subscribedChannels = installation.Channels;
            var result = new PluginResult(PluginResult.Status.OK, subscribedChannels);
            DispatchCommandResult(result);

        }
Esempio n. 14
0
        /// <summary>
        /// 更新安装进度
        /// </summary>
        /// <param name="type">类型标识:安装/卸载</param>
        /// <param name="progressState">进度状态</param>
        public override void OnProgressUpdated(AMS_OPERATION_TYPE type, InstallStatus progressState)
        {
            string res = String.Format("\"progress\":\"{0}\",\"type\":\"{1}\"", ((int)progressState).ToString(), ((int)type).ToString());
            res = "{" + res + "}";
            xFaceLib.Log.XLog.WriteInfo("-------------------AMS OnProgressUpdated result: " + res);

            //TODO: ams install progress
            PluginResult result = new PluginResult(PluginResult.Status.OK, res);
            result.KeepCallback = true;
            DispatchPluginResult(this, result);
        }
    public async void requestAccess(string unparsed)
    {
        var accountId = JsonHelper.Deserialize<string[]>(unparsed)[0];
        var module = AccountManager.GetAccountByName(accountId);

        AccountManager.SaveSate();
        IsolatedStorageSettings.ApplicationSettings["module"] = accountId;

        await module.RequestAccessAndContinue();

        PluginResult result = new PluginResult(PluginResult.Status.OK, module.GetAccessToken());
        DispatchCommandResult(result);
    }
Esempio n. 16
0
        public void GetDescription(string options)
        {
            PluginResult result;

            try
            {
                result = new PluginResult(PluginResult.Status.OK, "Cordova plugin by FrostAura to allow for adding events to Windows Phone native calendar.");
            }
            catch (Exception ex)
            {
                result = new PluginResult(PluginResult.Status.ERROR, ex.Message);
            }

            DispatchCommandResult(result);
        }
Esempio n. 17
0
        public void ToUpper(string options)
        {
            PluginResult result;

            try
            {
                string[] args = JsonHelper.Deserialize<string[]>(options);
                string[] calendarValues = args[0].Split('|');

                SaveAppointmentTask saveAppointmentTask = new SaveAppointmentTask();

                string title = calendarValues[0];
                string location = calendarValues[1];
                string notes = calendarValues[2];

                int appointmentYear = int.Parse(calendarValues[3]);
                int appointmentMonth = int.Parse(calendarValues[4]);
                int appointmentDay = int.Parse(calendarValues[5]);
                int fromHour = int.Parse(calendarValues[6]);
                int fromMinute = int.Parse(calendarValues[7]);
                int durationMinutes = int.Parse(calendarValues[8]);

                var startDateTime = new DateTime(appointmentYear, appointmentMonth, appointmentDay, fromHour, fromMinute,
                    0);
                var endDateTime = startDateTime.AddMinutes(durationMinutes);

                saveAppointmentTask.StartTime = startDateTime;
                saveAppointmentTask.EndTime = endDateTime;
                saveAppointmentTask.Subject = title;
                saveAppointmentTask.Location = location;
                saveAppointmentTask.Details = notes;
                saveAppointmentTask.IsAllDayEvent = false;
                saveAppointmentTask.Reminder = Reminder.OneHour;
                saveAppointmentTask.AppointmentStatus = AppointmentStatus.Busy;

                saveAppointmentTask.Show();

                result = new PluginResult(PluginResult.Status.OK, "Calendar event added successfully.");
            }
            catch (Exception ex)
            {
                result = new PluginResult(PluginResult.Status.ERROR, ex.Message);
            }

            DispatchCommandResult(result);
        }
Esempio n. 18
0
        public async void isSupported(string options)
        {
            PluginResult result = new PluginResult(PluginResult.Status.OK);
            result.KeepCallback = true;

            try
            {
                bool available = await StepCounter.IsSupportedAsync();
                result.Message = JsonHelper.Serialize(available);
                DispatchCommandResult(result);
            }
            catch (Exception ex)
            {
                result.Message = JsonHelper.Serialize(new { error = "isSupported", message = ex.Message });
                DispatchCommandResult(result);
            }
        }
        private void _setUp(string applicationId, string clientKey)
        {
            this.applicationId = applicationId;
            this.clientKey = clientKey;

            ParseClient.Initialize(appId, clientKey);
            await ParseInstallation.CurrentInstallation.SaveAsync();
            //String installationId = ParseInstallation.CurrentInstallation.InstallationId.ToString();
            //String objectId = ParseInstallation.CurrentInstallation.ObjectId.ToString();
            //var installation = ParseInstallation.CurrentInstallation;
            //IEnumerable<string> subscribedChannels = installation.Channels;

            PluginResult pr = new PluginResult(PluginResult.Status.OK, "onRegisterAsPushNotificationClientSucceeded");
            pr.KeepCallback = true;
            DispatchCommandResult(pr);
            //PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
            //pr.KeepCallback = true;
            //DispatchCommandResult(pr);
        }
Esempio n. 20
0
    public void register(string unparsedOptions)
    {
        var options = JsonHelper.Deserialize<string[]>(unparsedOptions)[0];
        var config = JsonHelper.Deserialize<PushConfig>(options);

        Registration registration = new Registration();
        registration.PushReceivedEvent += HandleNotification;
        registration.Register(new AeroGear.Push.PushConfig() { UnifiedPushUri = config.UnifiedPushUri, VariantId = config.VariantId, VariantSecret = config.VariantSecret });
        InvokeCustomScript(new ScriptCallback("eval", new string[] { "cordova.require('org.jboss.aerogear.cordova.push.AeroGear.UnifiedPush').successCallback()" }), false);

        PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
        result.KeepCallback = true;
        DispatchCommandResult(result);

        if (P.message != null)
        {
            HandleNotification(new Event() { Alert = P.message });
        }
    }
Esempio n. 21
0
        public async void initialize(string options)
        {
            PluginResult result = new PluginResult(PluginResult.Status.OK);
            result.KeepCallback = true;

            try
            {
                if (await StepCounter.IsSupportedAsync())
                {
                    stepCounter = await StepCounter.GetDefaultAsync();
                    isReady = true;
                }

                DispatchCommandResult(result);
            }
            catch (Exception ex)
            {
                result.Message = JsonHelper.Serialize(new { error = "init", message = ex.Message });
                DispatchCommandResult(result);
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Gets the count property of the live tile
        /// </summary>
        public void getBadge(string args)
        {
            // Application Tile is always the first Tile, even if it is not pinned to Start.
            ShellTile tile = ShellTile.ActiveTiles.First();

            // Application should always be found
            if (tile != null)
            {
                IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
                int badge = 0;
                PluginResult result;

                if (settings.Contains(KEY)) {
                    badge = (int)settings[KEY];
                }

                result = new PluginResult(PluginResult.Status.OK, badge);

                DispatchCommandResult(result);
            }
        }
Esempio n. 23
0
        public void AddEvent(string options)
        {
            PluginResult result;

            try
            {
                string[] args = JsonHelper.Deserialize<string[]>(options);
                string[] calendarValues = args[0].Split('|');

                SaveAppointmentTask saveAppointmentTask = new SaveAppointmentTask();

                int appointmentYear = int.Parse(calendarValues[3]);
                int appointmentMonth = int.Parse(calendarValues[4]);
                int appointmentDate = int.Parse(calendarValues[5]);
                float appointmentTime = float.Parse(calendarValues[6]);

                DateTime scheduleApptDateStart = (new DateTime(appointmentYear, appointmentMonth, appointmentDate, 7, 0, 0)).AddHours(appointmentTime);
                DateTime scheduleApptDateEnd = (new DateTime(appointmentYear, appointmentMonth, appointmentDate, 7, 30, 0)).AddHours(appointmentTime);

                saveAppointmentTask.StartTime = scheduleApptDateStart;
                saveAppointmentTask.EndTime = scheduleApptDateEnd;
                saveAppointmentTask.Subject = calendarValues[1];
                saveAppointmentTask.Location = calendarValues[2];
                saveAppointmentTask.Details = calendarValues[0];
                saveAppointmentTask.IsAllDayEvent = false;
                saveAppointmentTask.Reminder = Reminder.OneHour;
                saveAppointmentTask.AppointmentStatus = AppointmentStatus.Busy;

                saveAppointmentTask.Show();

                result = new PluginResult(PluginResult.Status.OK, "Calendar event added successfully.");
            }
            catch (Exception ex)
            {
                result = new PluginResult(PluginResult.Status.ERROR, ex.Message);
            }

            DispatchCommandResult(result);
        }
Esempio n. 24
0
        public void chooseContact(string arguments)
        {
            var task = new PickContactTask();

            task.Completed += delegate(Object sender, PickContactTask.PickResult e)
                {
                    if (e.TaskResult == TaskResult.OK)
                    {
                        string strResult = e.Contact.ToJson();
                        var result = new PluginResult(PluginResult.Status.OK)
                            {
                                Message = strResult
                            };
                        DispatchCommandResult(result);
                    }
                    if (e.TaskResult == TaskResult.Cancel)
                    {
                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Operation cancelled."));
                    }
                };

            task.Show();
        }
Esempio n. 25
0
		public void setUp(string args)
        {
            string adUnit = JsonHelper.Deserialize<string[]>(args)[0];
            Debug.WriteLine("adUnit: " + adUnit);
            string adUnitFullScreen = JsonHelper.Deserialize<string[]>(args)[1];
            Debug.WriteLine("adUnitFullScreen: " + adUnitFullScreen);
            bool isOverlap = Convert.ToBoolean(JsonHelper.Deserialize<string[]>(args)[2]);
            Debug.WriteLine("isOverlap: " + isOverlap);
            bool isTest = Convert.ToBoolean(JsonHelper.Deserialize<string[]>(args)[3]);
            Debug.WriteLine("isTest: " + isTest);

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {   
                _setUp(adUnit, adUnitFullScreen, isOverlap, isTest);
                
				PluginResult pr = new PluginResult(PluginResult.Status.OK);
				//pr.KeepCallback = true;
				DispatchCommandResult(pr);
				//PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
				//pr.KeepCallback = true;
				//DispatchCommandResult(pr);				
            });					
        }
    public async void register(string unparsedOptions)
    {
        var options = JsonHelper.Deserialize<string[]>(unparsedOptions)[0];
        var config = JsonHelper.Deserialize<PushConfig>(options);

        Registration registration = new MpnsRegistration();
        registration.PushReceivedEvent += HandleNotification;
        var pushConfig = Convert(config);
        await registration.Register(pushConfig);
        DispatchCommandResult(new PluginResult(PluginResult.Status.OK), ChannelId);

        PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
        result.KeepCallback = true;
        DispatchCommandResult(result);

        if (P.message != null)
        {
            if (config.SendMetricInfo)
            {
                await registration.SendMetricWhenAppLaunched(pushConfig, P.data[Registration.PUSH_ID_KEY]);
            }
            HandleNotification(new Event() { Alert = P.message, Payload = P.data });
        }
    }
        private void _unsubscribe(string channel)
        {
            await ParsePush.UnsubscribeAsync(channel);

            PluginResult pr = new PluginResult(PluginResult.Status.OK, "onUnsubscribeSucceeded");
            pr.KeepCallback = true;
            DispatchCommandResult(pr);
            //PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
            //pr.KeepCallback = true;
            //DispatchCommandResult(pr);
        }
 public async void connect(string options)
 {
     string[] args = null;
     try
     {
         args = WPCordovaClassLib.Cordova.JSON.JsonHelper.Deserialize<string[]>(options);
     }
     catch (FormatException)
     {
     }
     bleDevice = await BluetoothLEDevice.FromIdAsync(bleDevices[0].Id);
     currentDevice = bleDevice;
     string status;
     string CurrentDeviceName=null;
     string CurrentDeviceAddress = null;
     PluginResult result;
     if (currentDevice.ConnectionStatus.ToString() == "Disconnected")
     {
         await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-bluetooth:", UriKind.RelativeOrAbsolute));
         status = "connecting";
         CurrentDeviceAddress = currentDevice.BluetoothAddress.ToString();
         CurrentDeviceName = currentDevice.Name.ToString();
         callbackId_sub = args[args.Length-1];
         result = new PluginResult(PluginResult.Status.OK, "{\"status\":\"" + status + "\",\"address\":\"" + CurrentDeviceAddress + "\",\"name\":\"" + CurrentDeviceName + "\"}");
         result.KeepCallback = true;
         DispatchCommandResult(result, callbackId_sub);
     }
     while(currentDevice.ConnectionStatus.ToString() != "Connected")
     {}
     status = "connected";
     CurrentDeviceAddress = currentDevice.BluetoothAddress.ToString();
     CurrentDeviceName = currentDevice.Name.ToString();
     result = new PluginResult(PluginResult.Status.OK, "{\"status\":\"" + status + "\",\"address\":\"" + CurrentDeviceAddress + "\",\"name\":\"" + CurrentDeviceName + "\"}");
     result.KeepCallback = false;
     DispatchCommandResult(result, callbackId_sub);
 }
 public void characteristics_ValueChanged(GattCharacteristic sender, GattValueChangedEventArgs EventArgs)
 {
     string base64String = null;
     string JsonString=null;
     byte[] forceData = new byte[EventArgs.CharacteristicValue.Length];
     DataReader.FromBuffer(EventArgs.CharacteristicValue).ReadBytes(forceData);
     Thread.Sleep(waiting_time);
     base64String = System.Convert.ToBase64String(forceData, 0, forceData.Length);
     //currentDeviceCharacteristic[NotifyCharaIndex].Value = currentDeviceCharacteristic[NotifyCharaIndex].Value + System.Text.Encoding.UTF8.GetString(data, 0, (int)EventArgs.CharacteristicValue.Length);
     //JsonString = "\"" + System.Text.Encoding.UTF8.GetString(data, 0, (int)EventArgs.CharacteristicValue.Length)+ "\"";
     JsonString = "\"" + base64String + "\"";
     //JsonString = Regex.Replace(JsonString, "\n", "\\n");
     //JsonString = Regex.Replace(JsonString, "\r", "\\r");
     PluginResult result = new PluginResult(PluginResult.Status.OK, "{\"status\":\"subscribedResult\",\"value\":" + JsonString + "}");
     result.KeepCallback = true;
     DispatchCommandResult(result, callbackId_sub);
 }
 public void subscribe(string options)
 {
     string[] args = null;
     try
     {
         args = WPCordovaClassLib.Cordova.JSON.JsonHelper.Deserialize<string[]>(options);
     }
     catch (FormatException)
     {
     }
     JavaScriptArgs(args[0]);
     bool ShortUuidFlag = false;
     string servuuid = null;
     int index = 0;
     if (CurrentJSGattProfileArgs[0].service.Length == 4)
     {
         servuuid = GattCharacteristic.ConvertShortIdToUuid(Convert.ToUInt16(CurrentJSGattProfileArgs[0].service, 16)).ToString();
         ShortUuidFlag = true;
     }
     else
     {
         servuuid = CurrentJSGattProfileArgs[0].service;
     }
     for (int i = 0; i < currentDeviceServices.Length; i++)
     {
         if (currentDeviceServices[i].StrUuid == servuuid)
         {
             index = i;
         }
     }
     currentDeviceCharacteristic = new CharacteristicWithValue[CurrentJSGattProfileArgs[0].characteristics.Length];
     for (int i = 0; i < CurrentJSGattProfileArgs[0].characteristics.Length; i++)
     {
         if (ShortUuidFlag)
         {
             currentDeviceCharacteristic[i].GattCharacteristic = currentDevice.GattServices[index].
                 GetCharacteristics(GattCharacteristic.ConvertShortIdToUuid(Convert.ToUInt16(CurrentJSGattProfileArgs[0].characteristics[i], 16)))[0];
         }
         else
         {
             currentDeviceCharacteristic[i].GattCharacteristic = currentDevice.GattServices[index].GetCharacteristics(new Guid(CurrentJSGattProfileArgs[0].characteristics[i]))[0];
         }
         if (currentDeviceCharacteristic[i].GattCharacteristic.CharacteristicProperties.HasFlag(GattCharacteristicProperties.Notify))
         {
             Deployment.Current.Dispatcher.BeginInvoke(async () =>
             {
                 await currentDeviceCharacteristic[i].GattCharacteristic.WriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue.Notify);
                 Thread.Sleep(waiting_time);
                 currentDeviceCharacteristic[i].GattCharacteristic.ValueChanged += this.characteristics_ValueChanged;
             });
             callbackId_sub = args[args.Length - 1];
             PluginResult result = new PluginResult(PluginResult.Status.OK, "{\"status\":\"subscribed\",\"value\":\"\"}");
             result.KeepCallback = true;
             DispatchCommandResult(result, callbackId_sub);
             break;
         }
     }
 }