public UploadGUI(string deviceId, string[] files)
 {
     InitializeComponent();
     this.deviceId = deviceId;
     this.files    = files;
     PushBulletAPI.Configure(PushBulletAPI.GetNonNullConfigurationOption(PushBullet.conf, "apikey"));
     ProcessFile();
 }
Exemple #2
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);
            }
        }
        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;
            }
        }