private static void UpdateDevicesCache(Configuration conf, string apikey, bool updateKey)
 {
     PushBulletAPI.Configure(apikey);
     try
     {
         var res = PushBulletAPI.GetDevices();
         if (updateKey)
         {
             PushBulletAPI.SetConfigurationOption(conf, "apikey", apikey, false);
         }
         var serializer = new System.Xml.Serialization.XmlSerializer(typeof(PushBulletAPI.DevicesResponse));
         using (var writer = new System.IO.StringWriter())
         {
             serializer.Serialize(writer, res);
             PushBulletAPI.SetConfigurationOption(conf, "cachedDevices", writer.ToString(), true);
         }
         Console.WriteLine("OK");
     }
     catch (Exception e)
     {
         Console.Error.WriteLine("Invalid API key.");
         Console.Error.Write(e.ToString());
         System.Environment.Exit(1);
     }
 }
 public UploadGUI(string deviceId, string[] files)
 {
     InitializeComponent();
     this.deviceId = deviceId;
     this.files    = files;
     PushBulletAPI.Configure(PushBulletAPI.GetNonNullConfigurationOption(PushBullet.conf, "apikey"));
     ProcessFile();
 }
示例#3
0
        private void OnSaveBtnClicked(object sender, RoutedEventArgs e)
        {
            var key = apikeyInput.Text;

            /* Removed this check since I'm unsure if PushBullet's APIkey
             * is always 32 characters. Since it is an MD5 hash encoded with
             * Base64, I think that Base64's padding may alter its length,
             * so better leave this commented.
             * if (key.Length != 32)
             *  PushBullet.ShowError(Properties.Strings.InvalidKey);
             * else
             * {*/
            this.IsEnabled       = false;
            Mouse.OverrideCursor = Cursors.Wait;
            PushBulletAPI.Configure(key);
            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork             += CheckAPIKeyBg;
            bw.RunWorkerCompleted += UpdateUIElements;
            bw.RunWorkerAsync();
            //}
        }