Пример #1
0
 public APIGUI2()
 {
     InitializeComponent();
     if (PushBulletAPI.HasConfigurationOption(PushBullet.conf, "apikey"))
     {
         this.apikeyInput.Text = PushBulletAPI.GetNonNullConfigurationOption(PushBullet.conf, "apikey");
     }
     this.doneWindowChkBox.IsChecked = PushBulletAPI.GetBoolConfigurationOption(PushBullet.conf, "showDoneWindow", true);
     this.Loaded += WinLoaded;
 }
        /*private PushBulletAPI.DeviceCollection GetDevices()
         * {
         *  if (conf == null)
         *      conf = PushBulletAPI.GetSharedConfiguration("pushbullet");
         *  if (!PushBulletAPI.HasConfigurationOption(conf, "apikey")) throw new Exception("No device cache available");
         *  //var serializer = new System.Xml.Serialization.XmlSerializer(typeof(PushBulletAPI.DevicesResponse));
         *  //return serializer.Deserialize(new System.IO.StringReader(PushBulletAPI.GetNonNullConfigurationOption(conf, "cachedDevices"))) as PushBulletAPI.DevicesResponse;
         *
         * }*/

        private void TryExecute(string devId)
        {
            if (conf == null)
            {
                conf = PushBulletAPI.GetSharedConfiguration("pushbullet");
            }
            if (!PushBulletAPI.HasConfigurationOption(conf, "mainPath"))
            {
                throw new Exception("No executable path available");
            }
            try
            {
                Process.Start(PushBulletAPI.GetNonNullConfigurationOption(this.conf, "mainPath"), "/upload " + devId + " " + MergePaths(this.SelectedItemPaths));
            }
            catch (Exception exa)
            {
                MessageBox.Show("An error occurred while opening the upload helper: " + exa.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #3
0
 static void Main(string[] args)
 {
     conf = PushBulletAPI.GetSharedConfiguration("pushbullet");
     PushBulletAPI.SetConfigurationOption(conf, "mainPath", System.Reflection.Assembly.GetEntryAssembly().Location, true);
     if (args != null && args.Length > 2 && args[0].Equals("/upload"))
     {
         // enter upload mode
         if (!PushBulletAPI.HasConfigurationOption(conf, "apikey") || !System.Text.RegularExpressions.Regex.IsMatch(args[1], @"^\d+$"))
         {
             ShowError(Properties.Strings.InvalidParams);
             return;
         }
         new System.Windows.Application().Run(new UploadGUI(args[1], args.Skip(2).ToArray()));
     }
     else
     {
         new System.Windows.Application().Run(new APIGUI2());
     }
 }
        static void Main(string[] args)
        {
            if (args == null || args.Length < 1)
            {
                PrintUsage();
            }
            Configuration conf = PushBulletAPI.GetSharedConfiguration("pushbullet");

            switch (args[0].Substring(1))
            {
            case "apikey":
                if (args.Length < 2 || args[1].Length != 32)
                {
                    PrintUsage();
                }
                UpdateDevicesCache(conf, args[1], true);
                break;

            case "devices":
                if (!PushBulletAPI.HasConfigurationOption(conf, "cachedDevices"))
                {
                    Console.Error.WriteLine("No device cache available.");
                    System.Environment.Exit(1);
                }
                Console.Write(PushBulletAPI.GetNonNullConfigurationOption(conf, "cachedDevices"));
                break;

            case "refresh":
                if (!PushBulletAPI.HasConfigurationOption(conf, "apikey"))
                {
                    Console.Error.WriteLine("API key not set.");
                    System.Environment.Exit(1);
                }
                UpdateDevicesCache(conf, PushBulletAPI.GetNonNullConfigurationOption(conf, "apikey"), false);
                break;

            default:
                PrintUsage();
                break;
            }
        }