Exemple #1
0
        private void restartSyncManager()
        {
            if (manager != null)
            {
                manager.Stop();
            }

            string libPath = Properties.Settings.Default.LibraryPath;

            if (!AppLibrary.IsValidLibraryPath(libPath))
            {
                statusStripMainLabel.Text = "Cannot sync because [" + libPath + "] is not a valid Steam Library";
                return;
            }

            manager = new SyncManager(Properties.Settings.Default.BroadcastPort, Properties.Settings.Default.ListenPort, Properties.Settings.Default.LibraryPath);
            manager.OnSyncPeerUpdated      += managerUpdatedSyncPeer;
            manager.OnTransferCreated      += transferCreated;
            manager.OnTransferRemoved      += transferRemoved;
            manager.OnStatusUpdated        += managerUpdatedStatus;
            manager.OnAvailableAppsUpdated += managerUpdatedAvailableApps;
            try
            {
                manager.Start();
                refreshLibraryListView();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to sync your Steam library. " + ex.Message, "Cannot Sync", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemple #2
0
        public static AppLibrary FromDirectory(string path)
        {
            AppLibrary lib = new AppLibrary();

            lib._path = path;
            string  acf;
            AppInfo appInfo;

            DirectoryInfo di = new DirectoryInfo(path);

            foreach (FileInfo fi in di.GetFiles())
            {
                if (fi.Length < 10 * 1024)
                {
                    acf     = File.ReadAllText(fi.FullName);
                    appInfo = AppInfo.FromAcf(acf);
                    if (appInfo != null && appInfo.StateFlags == 4) // 4 = fully installed
                    {
                        lib.Apps.Add(appInfo.AppId, appInfo);
                    }
                }
            }

            return(lib);
        }
Exemple #3
0
 public SyncManager(int broadcastPort, int listenPort, string libraryPath)
 {
     BroadcastPort = broadcastPort;
     ListenPort    = listenPort;
     Library       = AppLibrary.FromDirectory(libraryPath);
     if (Library == null)
     {
         Debug.WriteLine(libraryPath + " is not a valid Steam Library");
         return;
     }
 }
Exemple #4
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            string libPath = Properties.Settings.Default.LibraryPath;

            if (AppLibrary.IsValidLibraryPath(libPath))
            {
                restartSyncManager();
            }
            else
            {
                string[] libs = AppLibrary.DetermineLibraryLocation();
                if (libs.Length == 1)
                {
                    DialogResult r = MessageBox.Show(String.Format("{0}\n\nIs this your Steam Library location?", libs[0]), "Library Location", MessageBoxButtons.YesNo);
                    if (r == DialogResult.Yes)
                    {
                        // set library location
                        Properties.Settings.Default.LibraryPath = libs[0];
                        Properties.Settings.Default.Save();
                        restartSyncManager();
                    }
                    else
                    {
                        // show "select library location" form
                        // todo provide autodetected paths to settings dialog
                        showSettingsDialog();
                    }
                }
                else
                {
                    // show "select library location" form
                    showSettingsDialog();
                }
                notifyIcon.ShowBalloonTip(15000, "Steam Library Location", "To change your Steam Library location, right-click this icon and select Settings.", ToolTipIcon.Info);
            }

            doLayout();
            this.Show();

            _updateSpeedTimer                     = new System.Timers.Timer(300);
            _updateSpeedTimer.Elapsed            += updateSpeedCounters;
            _updateSpeedTimer.AutoReset           = true;
            _updateSpeedTimer.SynchronizingObject = this;
            _updateSpeedTimer.Start();

            //notifyIcon.ShowBalloonTip(3000, "Hello world!", "This is a longer description\nwith another\nline", ToolTipIcon.None);
        }
Exemple #5
0
        public static AppManifest FromAppInfo(AppInfo app, AppLibrary library, bool hashFiles)
        {
            string libPath = library.Path;

            Utility.EnsureEndsWithSlash(ref libPath);
            DirectoryInfo di       = new DirectoryInfo(libPath + AppManifest.STEAM_COMMON_DIR + app.InstallDir);
            AppManifest   manifest = new AppManifest();

            manifest._hashFiles = hashFiles;

            try
            {
                manifest.AddDirectory(di, di);
            }
            catch (Exception e)
            {
                throw e;
            }

            return(manifest);
        }
Exemple #6
0
        public void Start()
        {
            if (Library == null)
            {
                throw new InvalidOperationException("Cannot start SyncManager without a valid library");
            }

            if (BroadcastPort == 0)
            {
                throw new InvalidOperationException("Cannot start SyncManager without a valid BroadcastPort");
            }

            if (ListenPort == 0)
            {
                throw new InvalidOperationException("Cannot start SyncManager without a valid ListenPort");
            }

            if (!AppLibrary.CanWriteToDirectory(Library.Path))
            {
                throw new ArgumentException("Cannot write to Library path " + Library.Path);
            }

            _udpAgent = new UdpAgent(BroadcastPort);
            _udpAgent.OnMessageReceived += new MessageReceivedEventHandler(handleMessage);
            _udpAgent.Start();

            _tcpAgent = new TcpAgent();
            _tcpAgent.OnMessageReceived += new MessageReceivedEventHandler(handleMessage);
            _tcpAgent.Start(BroadcastPort);

            // every 10 seconds, check for dead peers and remove from our list
            _deadPeerTimer           = new System.Timers.Timer(10000);
            _deadPeerTimer.Elapsed  += removeDeadPeers;
            _deadPeerTimer.AutoReset = true;
            _deadPeerTimer.Start();

            updateStatus(String.Format("Sharing {0} apps from library {1}", Library.Apps.Count, Library.Path));
        }
Exemple #7
0
 public static AppManifest FromAppInfo(AppInfo app, AppLibrary library)
 {
     return(FromAppInfo(app, library, false));
 }