/// <summary>
        /// Imports data from an API serialization object provided by CCP
        /// </summary>
        /// <param name="serial"></param>
        internal void Import(SerializableImplantSet serial)
        {
            // Search whether the api infos are different from the ones currently stored.
            var newSet = new ImplantSet(m_owner, "temp");

            newSet.Import(serial);

            bool isDifferent = false;
            var  oldArray    = m_api.ToArray();
            var  newArray    = newSet.ToArray();

            for (int i = 0; i < oldArray.Length; i++)
            {
                isDifferent |= (oldArray[i] != newArray[i]);
            }

            // Imports the API and make a backup
            if (isDifferent)
            {
                m_oldAPI.Import(m_api.Export(), false);
            }
            m_api.Import(serial);

            EveClient.OnSettingsChanged();
        }
Exemple #2
0
        /// <summary>
        /// Notify the user on a job completion.
        /// </summary>
        internal void UpdateOnTimerTick()
        {
            // We exit if there are no jobs
            if (m_items.IsEmpty())
            {
                return;
            }

            List <IndustryJob> jobsCompleted = new List <IndustryJob>();

            // Add the not notified "Ready" jobs to the completed list
            foreach (var job in m_items.Where(x => x.ActiveJobState == ActiveJobState.Ready && !x.NotificationSend))
            {
                jobsCompleted.Add(job);
                job.NotificationSend = true;
            }

            // We exit if no jobs have been completed
            if (jobsCompleted.IsEmpty())
            {
                return;
            }

            // Sends a notification
            EveClient.Notifications.NotifyIndustryJobCompletion(m_character, jobsCompleted);

            // Fires the event regarding industry jobs completed
            EveClient.OnCharacterIndustryJobsCompleted(m_character, jobsCompleted);
        }
        /// <summary>
        /// Processes the queried character's EVE notifications.
        /// </summary>
        /// <param name="result">The result.</param>
        private void OnCharacterEVENotificationsUpdated(APIResult <SerializableAPINotifications> result)
        {
            // Notify an error occured
            if (ShouldNotifyError(result, APIMethods.Notifications))
            {
                EveClient.Notifications.NotifyEVENotificationsError(this, result);
            }

            // Quits if there is an error
            if (result.HasError)
            {
                return;
            }

            // Import the data
            m_eveNotifications.Import(result.Result.Notifications);

            // Notify on new messages
            if (m_eveNotifications.NewNotifications != 0)
            {
                EveClient.Notifications.NotifyNewEVENotifications(this, m_eveNotifications.NewNotifications);
            }

            // Fires the event regarding EVE mail messages update
            EveClient.OnCharacterEVENotificationsUpdated(this);
        }
        /// <summary>
        /// Adds a notification to this collection.
        /// </summary>
        /// <param name="notification"></param>
        public void Notify(Notification notification)
        {
            //
            switch (notification.Behaviour)
            {
            case NotificationBehaviour.Cohabitate:
                m_items.Add(notification);
                break;

            case NotificationBehaviour.Overwrite:
                // Replace the previous notifications with the same invalidation key
                InvalidateCore(notification.InvalidationKey);
                m_items.Add(notification);
                break;

            case NotificationBehaviour.Merge:
                // Merge the notifications with the same key
                var key = notification.InvalidationKey;
                foreach (var other in m_items.Where(x => x.InvalidationKey == key))
                {
                    notification.Append(other);
                }

                // Replace the previous notifications with the same invalidation key
                InvalidateCore(key);
                m_items.Add(notification);
                break;
            }

            EveClient.OnNotificationSent(notification);
        }
Exemple #5
0
        /// <summary>
        /// Imports the character identities from a serialization object
        /// </summary>
        /// <param name="serial"></param>
        /// <param name="charactersGuid"></param>
        internal void Import(IEnumerable <SerializableSettingsCharacter> serial)
        {
            // Clear the accounts on every identity
            foreach (var id in EveClient.CharacterIdentities)
            {
                id.Account = null;
            }

            // Import the characters, their identies, etc
            m_items.Clear();
            foreach (var serialCharacter in serial)
            {
                // Gets the identity or create it
                var id = EveClient.CharacterIdentities[serialCharacter.ID];
                if (id == null)
                {
                    id = EveClient.CharacterIdentities.Add(serialCharacter.ID, serialCharacter.Name);
                }

                // Imports the character
                var ccpCharacter = serialCharacter as SerializableCCPCharacter;
                if (ccpCharacter != null)
                {
                    m_items.Add(new CCPCharacter(id, ccpCharacter));
                }
                else
                {
                    var uriCharacter = serialCharacter as SerializableUriCharacter;
                    m_items.Add(new UriCharacter(id, uriCharacter));
                }
            }

            // Notify the change
            EveClient.OnCharacterCollectionChanged();
        }
Exemple #6
0
        /// <summary>
        /// Tries to deserialize the EveIDToName file.
        /// </summary>
        private static void TryDeserializeCacheFile()
        {
            SerializableEveIDToName cache = null;

            // Deserialize the file
            cache = Util.DeserializeXML <SerializableEveIDToName>(s_file);

            // Reset the cache if anything went wrong
            if (cache.Entities.Any(x => x.ID == 0) || cache.Entities.Any(x => x.Name == String.Empty))
            {
                cache = null;
            }

            if (cache == null)
            {
                EveClient.Trace("Deserializing EveIDToName failed. File may be corrupt. Deleting file.");
                File.Delete(s_file);
                return;
            }

            // Add the data to the dictionary
            foreach (var entity in cache.Entities)
            {
                s_cacheList.Add(entity.ID, entity.Name);
            }
        }
 /// <summary>
 /// Invalidates the notifications with the given key and notify an event.
 /// </summary>
 /// <param name="args"></param>
 public void Invalidate(NotificationInvalidationEventArgs args)
 {
     if (InvalidateCore(args.Key))
     {
         EveClient.OnNotificationInvalidated(args);
     }
 }
Exemple #8
0
        /// <summary>
        /// Notify changes happened in the entries
        /// </summary>
        internal override void OnChanged(PlanChange change)
        {
            // Updates and notifications have been suspended
            if (m_changedNotificationSuppressions > 0)
            {
                m_change |= change;
                return;
            }

            // Changes are about to be fired
            change  |= m_change;
            m_change = PlanChange.None;

            // Add missing prerequisites
            if ((change & PlanChange.Prerequisites) != PlanChange.None)
            {
                FixPrerequisites();
            }

            // Notify changes
            if ((change & PlanChange.Notification) != PlanChange.None && m_isConnected)
            {
                EveClient.OnPlanChanged(this);
            }
        }
Exemple #9
0
        /// <summary>
        /// Gets or sets the implant for the given slot.
        /// </summary>
        /// <param name="slot">The slot for the implant to retrieve</param>
        /// <returns>The requested implant when found; null otherwise.</returns>
        public Implant this[ImplantSlots slot]
        {
            get
            {
                if (slot == ImplantSlots.None)
                {
                    return(null);
                }
                return(m_values[(int)slot]);
            }
            set
            {
                if (slot == ImplantSlots.None)
                {
                    throw new InvalidOperationException("Cannot assign 'none' slot");
                }

                if (value != null && value.Slot != slot)
                {
                    throw new InvalidOperationException("Slot mismatch");
                }

                if (value == null)
                {
                    value = Implant.None;
                }
                else
                {
                    m_values[(int)slot] = value;
                }

                EveClient.OnCharacterChanged(m_owner);
            }
        }
Exemple #10
0
        /// <summary>
        /// Occurs when CCP returns new data
        /// </summary>
        /// <param name="result"></param>
        private void OnMonitorUpdated(APIResult <SerializableServerStatus> result)
        {
            // Was there an error ?
            var lastStatus = m_status;

            if (result.HasError)
            {
                m_status = ServerStatus.Unknown;
                EveClient.Notifications.NotifyServerStatusError(result);
                return;
            }

            // Update status and users, notify no more errors
            m_users  = result.Result.Players;
            m_status = (result.Result.Open ? ServerStatus.Online : ServerStatus.Offline);
            EveClient.Notifications.InvalidateServerStatusError();

            // Notify subscribers about update
            EveClient.OnServerStatusUpdated(this, lastStatus, m_status);

            // Send a notification
            if (lastStatus != m_status)
            {
                EveClient.Notifications.NotifyServerStatusChange(m_status);
            }
            else
            {
                EveClient.Notifications.InvalidateServerStatusChange();
            }
        }
Exemple #11
0
        /// <summary>
        /// Imports data from a serialization object
        /// </summary>
        /// <param name="serial"></param>
        internal void Import(IEnumerable <SerializableQueuedSkill> serial)
        {
            m_isPaused = false;

            // If the queue is paused, CCP sends empty start and end time.
            // So we base the start time on when the skill queue was started.
            var startTimeWhenPaused = startTime;

            // Imports the queued skills and checks whether they are paused
            m_items.Clear();
            foreach (var serialSkill in serial)
            {
                // When the skill queue is paused, startTime and endTime are empty in the XML document.
                // As a result, the serialization leaves the DateTime with its default value.
                if (serialSkill.EndTime == default(DateTime))
                {
                    m_isPaused = true;
                }

                // Creates the skill queue
                m_items.Add(new QueuedSkill(m_character, serialSkill, m_isPaused, ref startTimeWhenPaused));
            }

            // Fires the event regarding the character skill queue update.
            EveClient.OnCharacterSkillQueueChanged(m_character);
        }
        private static void ScanUpdateFeed(SerializablePatch result)
        {
            Version currentVersion = Assembly.GetExecutingAssembly().GetName().Version;
            Version newestVersion  = new Version(result.Release.Version);
            string  forumUrl       = result.Release.TopicUrl;
            string  updateMessage  = result.Release.Message;
            string  installArgs    = result.Release.InstallerArgs;
            string  installerUrl   = result.Release.Url;
            string  additionalArgs = result.Release.AdditionalArgs;
            bool    canAutoInstall = (!String.IsNullOrEmpty(installerUrl) && !String.IsNullOrEmpty(installArgs));

            if (!String.IsNullOrEmpty(additionalArgs) && additionalArgs.Contains("%EVEMON_EXECUTABLE_PATH%"))
            {
                string appPath = Path.GetDirectoryName(Application.ExecutablePath);
                installArgs = String.Format(CultureConstants.DefaultCulture, "{0} {1}", installArgs, additionalArgs);
                installArgs = installArgs.Replace("%EVEMON_EXECUTABLE_PATH%", appPath);
            }

            // Is the program out of date ?
            if (newestVersion > currentVersion)
            {
                // Requests a notification to subscribers and quit
                EveClient.OnUpdateAvailable(forumUrl, installerUrl, updateMessage, currentVersion,
                                            newestVersion, canAutoInstall, installArgs);
                return;
            }

            if (result.FilesHaveChanged)
            {
                // Requests a notification to subscribers and quit
                EveClient.OnDataUpdateAvailable(forumUrl, result.ChangedDataFiles);
                return;
            }
        }
Exemple #13
0
        /// <summary>
        /// Called when the account status has been updated.
        /// </summary>
        /// <param name="result">The result.</param>
        private void OnAccountStatusUpdated(APIResult <SerializableAPIAccountStatus> result)
        {
            // Return on error
            if (result.HasError)
            {
                // Checks if EVE Backend Database is temporarily disabled
                if (result.EVEBackendDatabaseDisabled)
                {
                    return;
                }

                EveClient.Notifications.NotifyAccountStatusError(this, result);
                return;
            }

            EveClient.Notifications.InvalidateAccountError(this);

            m_accountCreated        = result.Result.CreateDate;
            m_accountExpirationDate = result.Result.PaidUntil;

            // Notifies for the account expiration
            NotifyAccountExpiration();

            // Fires the event regarding the account status update
            EveClient.OnAccountStatusUpdated(this);
        }
Exemple #14
0
        /// <summary>
        /// Processes the queried market orders.
        /// </summary>
        /// <param name="result"></param>
        private void OnMarketOrdersUpdated(APIResult <SerializableAPIOrderList> result)
        {
            // Notify an error occured
            if (ShouldNotifyError(result, APIMethods.MarketOrders))
            {
                EveClient.Notifications.NotifyMarketOrdersError(this, result);
            }

            // Quits if there is an error
            if (result.HasError)
            {
                return;
            }

            // Import the data
            var endedOrders = new List <MarketOrder>();

            m_marketOrders.Import(result.Result.Orders, endedOrders);

            // Sends a notification
            if (endedOrders.Count != 0)
            {
                EveClient.Notifications.NotifyMarkerOrdersEnding(this, endedOrders);
            }

            // Fires the event regarding market orders update.
            EveClient.OnCharacterMarketOrdersChanged(this);
        }
 /// <summary>
 /// Removes the provided character for the uri characters
 /// </summary>
 /// <param name="character">The character to remove</param>
 /// <exception cref="InvalidOperationException">This character does not have that identity</exception>
 public void Remove(UriCharacter character)
 {
     if (!m_uriCharacters.Remove(character))
     {
         throw new InvalidOperationException("This source does not belong to this character's sources");
     }
     EveClient.OnCharacterCollectionChanged();
 }
Exemple #16
0
 /// <summary>
 /// Adds a character to this collection.
 /// </summary>
 /// <param name="character"></param>
 /// <param name="notify"></param>
 internal void Add(Character character, bool notify)
 {
     m_items.Add(character);
     if (notify)
     {
         EveClient.OnCharacterCollectionChanged();
     }
 }
        /// <summary>
        /// Imports data from a serialization object
        /// </summary>
        /// <param name="serial"></param>
        public void Import(SerializableUriCharacter serial)
        {
            Import((SerializableSettingsCharacter)serial);

            m_uri = new Uri(serial.Uri);

            EveClient.OnCharacterChanged(this);
        }
        /// <summary>
        /// Update the order from the given list
        /// </summary>
        /// <param name="order"></param>
        public void Update(IEnumerable <Character> order)
        {
            m_items.Clear();
            m_items.AddRange(order);

            // Notify the change
            EveClient.OnMonitoredCharactersChanged();
        }
Exemple #19
0
 /// <summary>
 /// Imports data from the given character sheet informations
 /// </summary>
 /// <param name="serial">The serialized character sheet</param>
 internal void Import(APIResult <SerializableAPICharacter> serial)
 {
     if (!serial.HasError)
     {
         Import(serial.Result);
         EveClient.OnCharacterChanged(this);
     }
 }
 /// <summary>
 /// Adds an account to this collection.
 /// </summary>
 /// <param name="account"></param>
 /// <param name="notify"></param>
 internal void Add(Account account, bool notify)
 {
     m_items.Add(account.UserID, account);
     if (notify)
     {
         EveClient.OnAccountCollectionChanged();
     }
 }
Exemple #21
0
        /// <summary>
        /// Adds a new implant set.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public ImplantSet Add(string name)
        {
            var set = new ImplantSet(m_owner, name);

            m_customSets.Add(set);
            EveClient.OnCharacterChanged(m_owner);
            return(set);
        }
Exemple #22
0
 private static void LogException(Exception e, string header)
 {
     Trace.WriteLine("");
     EveClient.Trace(header);
     Trace.Indent();
     Trace.WriteLine(e.ToString());
     Trace.WriteLine("");
     Trace.Unindent();
 }
        /// <summary>
        /// Imports the serialized accounts
        /// </summary>
        /// <param name="serial"></param>
        internal void Import(IEnumerable <SerializableAccount> serial)
        {
            m_items.Clear();
            foreach (var serialAccount in serial)
            {
                m_items.Add(serialAccount.ID, new Account(serialAccount));
            }

            EveClient.OnAccountCollectionChanged();
        }
Exemple #24
0
        /// <summary>
        /// Imports data from the given character sheet informations
        /// </summary>
        /// <param name="serial">The serialized character sheet</param>
        internal void Import(APIResult <SerializableAPICharacterSheet> serial)
        {
            if (serial.HasError)
            {
                return;
            }

            Import(serial.Result);
            EveClient.OnCharacterChanged(this);
        }
Exemple #25
0
        /// <summary>
        /// Imports data from a serialization object
        /// </summary>
        /// <param name="serial"></param>
        public void Import(SerializablePlan serial)
        {
            // Update name
            m_name = serial.Name;
            m_sortingPreferences = serial.SortingPreferences.Clone();

            // Update entries
            List <PlanEntry>        entries        = new List <PlanEntry>();
            List <InvalidPlanEntry> invalidEntries = new List <InvalidPlanEntry>();

            foreach (var serialEntry in serial.Entries)
            {
                PlanEntry entry = new PlanEntry(this, serialEntry);

                if (entry.Skill != null)
                {
                    entries.Add(entry);
                }
                // There are buggy entries in the plan
                else
                {
                    var invalidEntry = new InvalidPlanEntry()
                    {
                        SkillName    = serialEntry.SkillName,
                        PlannedLevel = serialEntry.Level
                    };

                    invalidEntries.Add(invalidEntry);
                }
            }

            RebuildPlanFrom(entries);
            FixPrerequisites();

            foreach (var serialInvalidEntry in serial.InvalidEntries)
            {
                var invalidEntry = new InvalidPlanEntry()
                {
                    SkillName    = serialInvalidEntry.SkillName,
                    PlannedLevel = serialInvalidEntry.PlannedLevel,
                    Acknowledged = serialInvalidEntry.Acknowledged
                };

                invalidEntries.Add(invalidEntry);
            }

            m_invalidEntries = invalidEntries.ToArray();

            // Notify name change
            if (m_isConnected)
            {
                EveClient.OnPlanNameChanged(this);
            }
        }
        /// <summary>
        /// Addsa new UriCharacter with the specified Uri and deserialization object, then returns it
        /// </summary>
        /// <param name="uri">The source uri</param>
        /// <param name="result">The deserialization object acquired from the given uri</param>
        /// <returns>The created character, or null if there was errors on the provided CCP data.</returns>
        internal UriCharacter Add(Uri uri, APIResult <SerializableAPICharacterSheet> result)
        {
            if (result.HasError)
            {
                return(null);
            }

            var character = new UriCharacter(m_characterID, uri, result);

            m_uriCharacters.Add(character);

            EveClient.OnCharacterCollectionChanged();
            return(character);
        }
        /// <summary>
        /// Adds a character from a deserialization object
        /// </summary>
        /// <param name="serial"></param>
        internal void Add(SerializableUriCharacter serial)
        {
            var uriCharacter = this[new Uri(serial.Uri)];

            if (uriCharacter == null)
            {
                m_uriCharacters.Add(new UriCharacter(m_characterID, serial));
                EveClient.OnCharacterCollectionChanged();
            }
            else
            {
                uriCharacter.Import(serial);
            }
        }
Exemple #28
0
        /// <summary>
        /// Updates the characters list with the given CCP data.
        /// </summary>
        /// <param name="result"></param>
        internal void Import(APIResult <SerializableAPICharacters> result)
        {
            if (result.HasError)
            {
                ImportIdentities(null);
            }
            else
            {
                ImportIdentities(result.Result.Characters);
            }

            // Fires the event regarding the account character list update
            EveClient.OnCharacterListChanged(this);
        }
        /// <summary>
        /// Removes the provided account from this collection
        /// </summary>
        /// <param name="account">The account to remove</param>
        /// <param name="removeCharacters">When true, the associated characters will be removed.</param>
        /// <exception cref="InvalidOperationException">The account does not exist in the list.</exception>
        public void Remove(Account account, bool removeCharacters)
        {
            // Clears the account on the owned identities.
            foreach (var identity in account.CharacterIdentities.Where(x => x.Account == account))
            {
                identity.Account = null;
            }

            // Remove the account
            if (!m_items.Remove(account.UserID))
            {
                throw new InvalidOperationException("This account does not exist in the list.");
            }

            EveClient.OnAccountCollectionChanged();
        }
        /// <summary>
        /// Imports the given characters
        /// </summary>
        /// <param name="characterGuids"></param>
        internal void Import(List <MonitoredCharacterSettings> monitoredCharacters)
        {
            m_items.Clear();
            foreach (var characterSettings in monitoredCharacters)
            {
                var character = EveClient.Characters[characterSettings.CharacterGuid];
                if (character != null)
                {
                    m_items.Add(character);
                    character.Monitored  = true;
                    character.UISettings = characterSettings.Settings;
                }
            }

            EveClient.OnMonitoredCharactersChanged();
        }