コード例 #1
0
        private static void LoadBuddyListNames()
        {
            //get the buddy list from the session
            AccCoreLib.IAccBuddyList bl = accSess.BuddyList;

            //list of users
            List <String> lst = new List <string>();

            //iterate groups
            for (int i = 0; i < bl.GroupCount; i++)
            {
                //iterate names in the group
                for (int j = 0; j < bl.GetGroupByIndex(i).BuddyCount; j++)
                {
                    //get user
                    IAccUser user = bl.GetGroupByIndex(i).GetBuddyByIndex(j);

                    //add user to dictionary
                    lst.Add(user.Name);
                }
            }

            //raise the NamesLoaded event
            if (NamesLoaded != null)
            {
                NamesLoaded.Invoke(lst);
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets if the Buddy is Idle. This is necessary because Buddies are not always reported as Idle for some strange AOL known reason.
        /// </summary>
        /// <param name="BuddyName">The Name of the Buddy to check.</param>
        /// <returns>Returns true if the Buddy is Idle, false else.</returns>
        public static void CheckBuddyIdle(String BuddyName)
        {
            //get the buddy list
            IAccBuddyList bl = accSess.BuddyList;

            //get the user
            IAccUser usr = bl.GetBuddyByName(BuddyName);

            //sanity check: null user
            if (usr == null)
            {
                return;
            }

            //request idle
            usr.RequestProperty(AccUserProp.AccUserProp_IdleTime);
        }
コード例 #3
0
        private static void BuddyStateChanged(IAccUser user, InternalUserStateFlags state)
        {
            //temp buddy list var
            IAccBuddyList bl = accSess.BuddyList;

            //name of user/groups
            String strName = user.Name;

            String[] arrGroups = GetUsersGroupsNames(user);

            switch (state)
            {
            case InternalUserStateFlags.SignedOffline:
                //raise offline event
                if (BuddySignedOffline != null)
                {
                    BuddySignedOffline.Invoke(strName, arrGroups);
                }
                break;

            case InternalUserStateFlags.SignedOnline:
                //raise online event
                if (BuddySignedOnline != null)
                {
                    BuddySignedOnline.Invoke(strName, arrGroups);
                }
                break;

            case InternalUserStateFlags.WentAway:
                //raise away event
                if (BuddyWentAway != null)
                {
                    BuddyWentAway.Invoke(strName, arrGroups);
                }
                break;

            case InternalUserStateFlags.WentIdle:
                //raise idle event
                if (BuddyWentIdle != null)
                {
                    BuddyWentIdle.Invoke(strName, arrGroups);
                }
                break;
            }
        }
コード例 #4
0
        public static String[] GetUsersGroupsNames(IAccUser user)
        {
            //get the groups as an object
            object[] groups = (object[])user.Groups;

            //array of names
            String[] names = new String[groups.Length];

            //set the name
            for (int i = 0; i < groups.Length; i++)
            {
                IAccGroup g = (IAccGroup)groups[i];
                names[i] = g.Name;
            }

            //return array
            return(names);
        }
コード例 #5
0
        /// <summary>
        /// Gets the Position of the Buddy in the specified Group.
        /// </summary>
        /// <param name="BuddyName">The Name of the Buddy to get the Position of.</param>
        /// <param name="GroupName">The Name of the Group the specified Buddy belongs to.</param>
        /// <returns>Returns the Position of the specified Buddy.</returns>
        public static int BuddyPosition(String BuddyName, String GroupName)
        {
            //get the buddy list
            IAccBuddyList bl = accSess.BuddyList;

            //get the group
            IAccGroup grp = bl.GetGroupByName(GroupName);

            //get the buddy
            IAccUser usr = bl.GetBuddyByName(BuddyName);

            //sanity check: null group
            if (grp == null)
            {
                return(-1);
            }

            //return the Buddy's position
            return(grp.GetBuddyPosition(usr));
        }
コード例 #6
0
 static void session_OnBuddyAdded(AccSession session, IAccGroup group, IAccUser user, int position, AccResult hr)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
 static void session_OnBuddyMoved(AccSession session, IAccUser user, IAccGroup fromGroup, int fromPosition, IAccGroup toGroup, int toPosition, AccResult hr)
 {
     throw new NotImplementedException();
 }
コード例 #8
0
        private static void accSess_OnUserRequestPropertyResult(AccSession session, IAccUser user, AccUserProp Property, int transId, AccResult hr, object propertyValue)
        {
            //if its the idle time, raise the event if necessary
            if (Property == AccUserProp.AccUserProp_IdleTime)
            {
                //if the user's idle time is > 0 then raise idle event
                if ((int)propertyValue > 0)
                {
                    BuddyWentIdle(user.Name, GetUsersGroupsNames(user));
                }
            }
            else if (Property == AccUserProp.AccUserProp_Profile)
            {
                //profile is actually an IM object
                IAccIm im = (IAccIm)propertyValue;

                //dequeue the request
                Actions.QueueOfRequests.Dequeue();

                //check that this is the last queued request
                if (Actions.QueueOfRequests.Count < 1)
                {
                    //add the profile to the return var
                    strReturnRequest += im.GetConvertedText(MIME_TYPE);

                    //invoke info received event
                    if (InfoReceived != null)
                    {
                        InfoReceived.Invoke(user.Name, strReturnRequest);
                    }
                }
                else
                {
                    //add the profile to the return
                    strReturnRequest = im.GetConvertedText(MIME_TYPE);
                }
            }
            else if (Property == AccUserProp.AccUserProp_AwayMessage)
            {
                //away message is actually an IM object
                IAccIm im = (IAccIm)propertyValue;

                //dequeue the request
                Actions.QueueOfRequests.Dequeue();

                //check the request count
                if (Actions.QueueOfRequests.Count < 1)
                {
                    //put this text at the beginning of the request
                    strReturnRequest = im.GetConvertedText(MIME_TYPE) + strReturnRequest;

                    //invoke away message reveived event
                    if (AwayMessageReceived != null)
                    {
                        AwayMessageReceived.Invoke(user.Name, strReturnRequest);
                    }
                }
                else
                {
                    //set the return request var as the decoded string
                    strReturnRequest = im.GetConvertedText(MIME_TYPE);
                }
            }
        }
コード例 #9
0
        private static void accSess_OnUserChange(AccSession session, IAccUser oldUser, IAccUser newUser, AccUserProp Property, AccResult hr)
        {
            //get states
            AccUserState oldState = (AccUserState)oldUser.get_Property(AccUserProp.AccUserProp_State);
            AccUserState newState = (AccUserState)newUser.get_Property(AccUserProp.AccUserProp_State);

            //compare old state to the new state to figure out what happened to the buddy
            switch (oldState)
            {
            case AccUserState.AccUserState_Away:
                switch (newState)
                {
                case AccUserState.AccUserState_Idle:
                    //buddy went from just Away to Away and Idle
                    BuddyStateChanged(newUser, InternalUserStateFlags.WentIdle);
                    break;

                case AccUserState.AccUserState_Offline:
                case AccUserState.AccUserState_Unknown:
                    //buddy went from Away to Offline
                    BuddyStateChanged(newUser, InternalUserStateFlags.SignedOffline);
                    break;

                case AccUserState.AccUserState_Online:
                    //buddy went from Away to just Online (aka took away down)
                    BuddyStateChanged(newUser, InternalUserStateFlags.SignedOnline);
                    break;
                }
                break;

            case AccUserState.AccUserState_Idle:
                switch (newState)
                {
                case AccUserState.AccUserState_Away:
                    //buddy went from just Idle to Away and Idle
                    BuddyStateChanged(newUser, InternalUserStateFlags.WentAway);
                    break;

                case AccUserState.AccUserState_Offline:
                case AccUserState.AccUserState_Unknown:
                    //buddy went from Idle to Offline
                    BuddyStateChanged(newUser, InternalUserStateFlags.SignedOffline);
                    break;

                case AccUserState.AccUserState_Online:
                    //buddy went from Idle to Online (aka no longer Idle)
                    BuddyStateChanged(newUser, InternalUserStateFlags.SignedOnline);
                    break;
                }
                break;

            case AccUserState.AccUserState_Offline:
            case AccUserState.AccUserState_Unknown:
                switch (newState)
                {
                case AccUserState.AccUserState_Away:
                    //buddy went from Offline to Away (aka Signed On then Went Away)
                    BuddyStateChanged(newUser, InternalUserStateFlags.SignedOnline);
                    BuddyStateChanged(newUser, InternalUserStateFlags.WentAway);
                    break;

                case AccUserState.AccUserState_Idle:
                    //buddy went from Offline to Idle (aka Signed On then Went Idle)
                    BuddyStateChanged(newUser, InternalUserStateFlags.SignedOnline);
                    BuddyStateChanged(newUser, InternalUserStateFlags.WentIdle);
                    break;

                case AccUserState.AccUserState_Offline:
                case AccUserState.AccUserState_Unknown:
                    //buddy went from Offline/Unknown to Offline/Unknown
                    BuddyStateChanged(newUser, InternalUserStateFlags.SignedOffline);
                    break;

                case AccUserState.AccUserState_Online:
                    //buddy went from Offline to Online
                    BuddyStateChanged(newUser, InternalUserStateFlags.SignedOnline);
                    break;
                }
                break;

            case AccUserState.AccUserState_Online:
                switch (newState)
                {
                case AccUserState.AccUserState_Away:
                    //buddy went from Online to Away
                    BuddyStateChanged(newUser, InternalUserStateFlags.WentAway);
                    break;

                case AccUserState.AccUserState_Idle:
                    //buddy went from Online to Idle
                    BuddyStateChanged(newUser, InternalUserStateFlags.WentIdle);
                    break;

                case AccUserState.AccUserState_Offline:
                case AccUserState.AccUserState_Unknown:
                    //buddy went from Online to Offline/Unknown
                    BuddyStateChanged(newUser, InternalUserStateFlags.SignedOffline);
                    break;
                }
                break;
            }
        }
コード例 #10
0
 public static IAccImSession CreateOrGetSession(IAccUser User, AccImSessionType Type)
 {
     return(CreateOrGetSession(User.Name, Type));
 }