/// <summary>
 /// Constructor from the API.
 /// </summary>
 /// <param name="src"></param>
 internal EveNotification(CCPCharacter ccpCharacter, SerializableNotificationsListItem src)
 {
     m_ccpCharacter = ccpCharacter;
     NotificationID = src.NotificationID;
     Type = EveNotificationType.GetType(src.TypeID);
     Sender = GetIDToName(src.SenderID);
     SentDate = src.SentDate;
     Recipient = GetRecipient();
 }
 /// <summary>
 /// Constructor from the API.
 /// </summary>
 /// <param name="src"></param>
 internal EveMailMessage(CCPCharacter ccpCharacter, SerializableMailMessagesListItem src)
 {
     m_ccpCharacter = ccpCharacter;
     State = (src.SenderID != ccpCharacter.CharacterID ?
                 EVEMailState.Inbox : EVEMailState.SentItem);
     MessageID = src.MessageID;
     Sender = src.ToListID.Any(x => x == src.SenderID.ToString()) ?
                 GetMailingListIDToName(src.SenderID.ToString()) : EveIDtoName.GetIDToName(src.SenderID.ToString());
     SentDate = src.SentDate;
     Title = src.Title;
     ToCorpOrAlliance = EveIDtoName.GetIDToName(src.ToCorpOrAllianceID);
     ToCharacters = GetIDsToNames(src.ToCharacterIDs);
     ToMailingLists = GetMailingListIDsToNames(src.ToListID);
     Recipient = GetRecipient();
 }
 /// <summary>
 /// Adds a character from a deserialization object
 /// </summary>
 /// <param name="ccpCharacter"></param>
 internal void Add(SerializableCCPCharacter ccpCharacter)
 {
     m_ccp = new CCPCharacter(m_characterID, ccpCharacter);
 }
Exemple #4
0
        /// <summary>
        /// Called when character's skill in training gets updated.
        /// </summary>
        /// <param name="result">The result.</param>
        /// <param name="character">The character's name.</param>
        private void OnSkillInTrainingUpdated(APIResult <SerializableAPISkillInTraining> result, string characterName)
        {
            CCPCharacter ccpCharacter = EveClient.Characters.FirstOrDefault(x => x.Name == characterName) as CCPCharacter;

            // Return on error
            if (result.HasError)
            {
                // Checks if EVE Backend Database is temporarily disabled
                if (result.EVEBackendDatabaseDisabled)
                {
                    return;
                }

                if (ccpCharacter != null)
                {
                    EveClient.Notifications.NotifySkillInTrainingError(ccpCharacter, result);
                }

                m_skillInTrainingCache[characterName].State = ResponseState.InError;
                return;
            }

            if (ccpCharacter != null)
            {
                EveClient.Notifications.InvalidateCharacterAPIError(ccpCharacter);
            }

            m_skillInTrainingCache[characterName].State = result.Result.SkillInTraining == 1
                                                     ? ResponseState.Training
                                                     : ResponseState.NotTraining;

            // In the event this becomes a very long running process because of latency
            // and characters have been removed from the account since they were queried
            // remove those characters from the cache
            IEnumerable <KeyValuePair <string, SkillInTrainingResponse> > toRemove =
                m_skillInTrainingCache.Where(x => !CharacterIdentities.Any(y => y.Name == x.Key));

            foreach (var charToRemove in toRemove)
            {
                m_skillInTrainingCache.Remove(charToRemove.Key);
            }

            // If we did not get response from a character in account yet
            // or there was an error in any responce,
            // we are not sure so wait until next time
            if (m_skillInTrainingCache.Any(x => x.Value.State == ResponseState.Unknown ||
                                           x.Value.State == ResponseState.InError))
            {
                return;
            }

            // We have successful responces from all characters in account,
            // so we notify the user and fire the event
            NotifyAccountNotInTraining();

            // Fires the event regarding the account characters skill in training update
            EveClient.OnAccountCharactersSkillInTrainingUpdated(this);

            // Reset update pending flag
            m_updatePending = false;
        }
Exemple #5
0
        /// <summary>
        /// Updates the account with the informations extracted from the API by <see cref="AccountCreationEventArgs"/>.
        /// </summary>
        /// <param name="apiKey"></param>
        /// <param name="keyLevel"></param>
        /// <param name="identities"></param>
        /// <param name="charListQueryResult"></param>
        internal void UpdateAPIKey(string apiKey, CredentialsLevel keyLevel, IEnumerable<CharacterIdentity> identities,
                                    APIResult<SerializableAPICharacters> charListQueryResult,
                                    APIResult<SerializableAPIAccountStatus> accountStatusQueryResult)
        {
            m_apiKey = apiKey;
            m_keyLevel = keyLevel;
            m_charactersListMonitor.UpdateWith(charListQueryResult);
            m_accountStatusMonitor.UpdateWith(accountStatusQueryResult);

            // Clear the account for the currently associated identities
            foreach (CharacterIdentity id in EveClient.CharacterIdentities)
            {
                if (id.Account == this)
                    id.Account = null;
            }

            // Assign this account to the new identities and create CCP characters
            foreach (CharacterIdentity id in identities)
            {
                // Skip if in the ignore list
                id.Account = this;
                if (m_ignoreList.Contains(id))
                    continue;

                // Retrieves the ccp character and create one if none
                CCPCharacter ccpCharacter = id.CCPCharacter;
                if (ccpCharacter == null)
                {
                    ccpCharacter = new CCPCharacter(id);
                    EveClient.Characters.Add(ccpCharacter, true);
                    ccpCharacter.Monitored = true;
                }
            }
        }
 /// <summary>
 /// Invalidates the notification for skill queue availability.
 /// </summary>
 internal void InvalidateSkillQueueRoomAvailability(CCPCharacter character)
 {
     Invalidate(new NotificationInvalidationEventArgs(character, NotificationCategory.SkillQueueRoomAvailable));
 }
 /// <summary>
 /// Invalidates the notification for a skill completion.
 /// </summary>
 internal void InvalidateSkillCompletion(CCPCharacter character)
 {
     Invalidate(new NotificationInvalidationEventArgs(character, NotificationCategory.SkillCompletion));
 }
Exemple #8
0
 /// <summary>
 /// Default constructor, only used by <see cref="Character"/>
 /// </summary>
 /// <param name="character">The character this collection is bound to.</param>
 public SkillQueue(CCPCharacter character)
 {
     m_character = character;
 }
 /// <summary>
 /// Invalidates the notification for a character's API error.
 /// </summary>
 internal void InvalidateCharacterAPIError(CCPCharacter character)
 {
     Invalidate(new NotificationInvalidationEventArgs(character, NotificationCategory.QueryingError));
 }
Exemple #10
0
 /// <summary>
 /// On skill completion, switch to the display of the proper message.
 /// </summary>
 public void SkillCompleted(Character character, int skillCount)
 {
     CurrentCharacter = character as CCPCharacter;
     m_completedSkills = skillCount;
     SwitchState(LcdState.SkillComplete);
 }
Exemple #11
0
        /// <summary>
        /// Sends a mail alert for a skill completion
        /// </summary>
        /// <param name="queueList">Current Skill Queue</param>
        /// <param name="skill">Skill that has just completed</param>
        /// <param name="character">Character affected</param>
        /// <returns></returns>
        public static bool SendSkillCompletionMail(IList <QueuedSkill> queueList, QueuedSkill skill, Character character)
        {
            CCPCharacter ccpCharacter = character as CCPCharacter;

            // Current character isn't a CCP character, so can't have a Queue.
            if (ccpCharacter == null)
            {
                return(false);
            }

            string charName         = character.Name;
            string skillName        = skill.SkillName;
            string skillLevelString = Skill.GetRomanForInt(skill.Level);

            var      skillQueueEndTime = ccpCharacter.SkillQueue.EndTime;
            bool     freeTime          = skillQueueEndTime < DateTime.UtcNow.AddHours(24);
            TimeSpan timeLeft          = DateTime.UtcNow.AddHours(24).Subtract(skillQueueEndTime);
            string   timeLeftText      = timeLeft.ToDescriptiveText(DescriptiveTextOptions.IncludeCommas, false);

            // Message's first line
            StringBuilder body = new StringBuilder();

            body.AppendFormat(CultureConstants.DefaultCulture, "{0} has finished training {1} {2}.{3}{3}", charName, skillName, skillLevelString, Environment.NewLine);

            // Next skills in queue
            if (queueList[0] != null)
            {
                body.AppendFormat(CultureConstants.DefaultCulture, "Next skill{0} in queue:{1}", (queueList.Count > 1 ? "s" : String.Empty), Environment.NewLine);
                foreach (var qskill in queueList)
                {
                    body.AppendFormat(CultureConstants.DefaultCulture, "- {0}{1}", qskill, Environment.NewLine);
                }
                body.AppendLine();
            }
            else
            {
                body.AppendFormat(CultureConstants.DefaultCulture, "Character is not training.{0}{0}", Environment.NewLine);
            }

            // Free room in skill queue
            if (freeTime)
            {
                body.AppendFormat(CultureConstants.DefaultCulture, "There is also {0} free room in skill queue.{1}", timeLeftText, Environment.NewLine);
            }

            // Short format (also for SMS)
            if (Settings.Notifications.UseEmailShortFormat)
            {
                return(SendMail(Settings.Notifications, String.Format(CultureConstants.DefaultCulture, "[STC] {0} :: {1} {2}", charName, skillName, skillLevelString), body.ToString()));
            }

            // Long format
            if (character.Plans.Count > 0)
            {
                body.AppendFormat(CultureConstants.DefaultCulture, "Next skills listed in plans:{0}{0}", Environment.NewLine);
            }

            foreach (var plan in character.Plans)
            {
                if (plan.Count > 0)
                {
                    // Print plan name
                    CharacterScratchpad scratchpad = new CharacterScratchpad(character);
                    body.AppendFormat(CultureConstants.DefaultCulture, "{0}:{1}", plan.Name, Environment.NewLine);

                    // Scroll through entries
                    int i       = 0;
                    int minDays = 1;
                    foreach (PlanEntry entry in plan)
                    {
                        TimeSpan trainTime = scratchpad.GetTrainingTime(entry.Skill, entry.Level, TrainingOrigin.FromPreviousLevelOrCurrent);

                        // Only print the first three skills, and the very long skills
                        // (first limit is one day, then we add skills duration)
                        if (++i <= 3 || trainTime.Days > minDays)
                        {
                            if (i > 3)
                            {
                                // Print long message once
                                if (minDays == 1)
                                {
                                    body.AppendFormat(CultureConstants.DefaultCulture, "{1}Longer skills from {0}:{1}", plan.Name, Environment.NewLine);
                                }

                                minDays = trainTime.Days + minDays;
                            }
                            body.AppendFormat(CultureConstants.DefaultCulture, "\t{0}", entry);

                            // Notes
                            if (entry.Notes != null && entry.Notes.Length > 0)
                            {
                                body.AppendFormat(CultureConstants.DefaultCulture, " ({0})", entry.Notes);
                            }

                            // Training time
                            if (trainTime.Days > 0)
                            {
                                body.AppendFormat(CultureConstants.DefaultCulture, " - {0}d, {1}", trainTime.Days, trainTime);
                            }
                            else
                            {
                                body.AppendFormat(CultureConstants.DefaultCulture, " - {0}", trainTime);
                            }

                            body.AppendLine();
                        }
                    }
                    body.AppendLine();
                }
            }

            string subject = String.Format(CultureConstants.DefaultCulture, "{0} has finished training {1} {2}", charName, skillName, skillLevelString);

            return(SendMail(Settings.Notifications, subject, body.ToString()));
        }
Exemple #12
0
 /// <summary>
 /// On skill completion, switch to the display of the proper message.
 /// </summary>
 public void SkillCompleted(Character character)
 {
     CurrentCharacter = character as CCPCharacter;
     SwitchState(LcdState.SkillComplete);
 }
Exemple #13
0
        /// <summary>
        /// Occurs when some of the G15 screen buttons are pressed.
        /// </summary>
        /// <param name="device"></param>
        /// <param name="dwButtons"></param>
        /// <param name="pContext"></param>
        /// <returns></returns>
        private int OnButtonsPressed(int device, int dwButtons, IntPtr pContext)
         {
            if (m_oldButtonState == dwButtons)
                return 0;

            // Gets all buttons who haven't been pressed last time
            int press = (m_oldButtonState ^ dwButtons) & dwButtons;

            // Displays the characters' list or move to the next char if the list is already displayed.
            if ((press & LCDInterface.LGLCDBUTTON_BUTTON0) != 0)
                DisplayCharactersList();

            // Move to the first character to complete his training
            if ((press & LCDInterface.LGLCDBUTTON_BUTTON1) != 0)
            {
                // Select next skill ready char
                if (Characters == null)
                    return 0;

                CurrentCharacter = FirstCharacterToCompleteSkill as CCPCharacter;

                if (AutoCycleChanged != null)
                    AutoCycleChanged(false);

                SwitchState(LcdState.Character);
            }

            // Forces a refresh from CCP
            if ((press & LCDInterface.LGLCDBUTTON_BUTTON2) != 0)
            {
                if (m_state == LcdState.Character || m_state == LcdState.CharacterList)
                {
                    RefreshCharacter = CurrentCharacter;
                    if (APIUpdateRequested != null)
                        APIUpdateRequested(RefreshCharacter);

                    SwitchState(LcdState.Refreshing);
                }
            }

            // Switch autocycle ON/OFF
            if ((press & LCDInterface.LGLCDBUTTON_BUTTON3) != 0)
            {
                // Switch autocycle on/off
                SwitchCycle();

                if (AutoCycleChanged != null)
                    AutoCycleChanged(Cycle);

                SwitchState(LcdState.CycleSettings);
                m_cycleTime = DateTime.Now;
            }

            m_oldButtonState = dwButtons;
            return 0;
        }
Exemple #14
0
        /// <summary>
        /// Appends the given training time for the specified character to the provided <see cref="StringBuilder"/>. *
        /// Format is : "1d, 5h, 32m John Doe (Eidetic Memory)"
        /// Used to update the window's title.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="character"></param>
        /// <param name="time"></param>
        private static string AppendCharacterTrainingTime(CCPCharacter character, TimeSpan time)
        {
            StringBuilder builder = new StringBuilder();

            string skillDescriptionText = time.ToDescriptiveText(DescriptiveTextOptions.Default);
            builder.AppendFormat(CultureConstants.DefaultCulture,"{0} {1}", skillDescriptionText, character.Name);

            if (Settings.UI.MainWindow.ShowSkillNameInWindowTitle)
                builder.AppendFormat(CultureConstants.DefaultCulture, " ({0})", character.CurrentlyTrainingSkill.SkillName);

            return builder.ToString();
        }
 /// <summary>
 /// Default constructor, this class is only instantiated by CharacterIdentity
 /// </summary>
 /// <param name="character">The character identitity this collection is bound to.</param>
 internal CharacterCollection(CharacterIdentity characterID)
 {
     m_characterID = characterID;
     m_ccp         = new CCPCharacter(characterID);
 }
 /// <summary>
 /// Invalidates the notification for an insufficient clone.
 /// </summary>
 internal void InvalidateInsufficientClone(CCPCharacter character)
 {
     Invalidate(new NotificationInvalidationEventArgs(character, NotificationCategory.InsufficientClone));
 }
        /// <summary>
        /// Updates all the content
        /// </summary>
        private void UpdateContent()
        {
            // Returns if not visible
            if (!Visible)
                return;

            // When no character, we just clear the list
            if (Character == null)
            {
                noSkillsQueueLabel.Visible = true;
                lbSkillsQueue.Visible = false;
                lbSkillsQueue.Items.Clear();
                return;
            }

            m_ccpCharacter = Character as CCPCharacter;

            // If the character is not a CCPCharacter it does not have a skill queue
            if (m_ccpCharacter == null)
                return;

            // When the skill queue hasn't changed don't do anything
            if (!QueueHasChanged(m_ccpCharacter.SkillQueue.ToArray()))
                return;

            m_skillQueue = m_ccpCharacter.SkillQueue.ToArray();

            // Update the skills queue list
            lbSkillsQueue.BeginUpdate();
            try
            {
                // Add items in the list
                lbSkillsQueue.Items.Clear();
                foreach (QueuedSkill skill in m_ccpCharacter.SkillQueue)
                {
                    lbSkillsQueue.Items.Add(skill);
                }

                // Display or hide the "no queue skills" label.
                noSkillsQueueLabel.Visible = m_ccpCharacter.SkillQueue.IsEmpty();
                lbSkillsQueue.Visible = !m_ccpCharacter.SkillQueue.IsEmpty();

                // Invalidate display
                lbSkillsQueue.Invalidate();
            }
            finally
            {
                lbSkillsQueue.EndUpdate();
            }
        }
Exemple #18
0
 /// <summary>
 /// Internal constructor.
 /// </summary>
 internal EveMailMessagesCollection(CCPCharacter ccpCharacter)
 {
     m_ccpCharacter = ccpCharacter;
 }