Exemplo n.º 1
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);
                }
            }
        }
Exemplo n.º 2
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;
            }
        }