private IQ SetPrivateLog(XmppStream stream, IQ iq, XmppHandlerContext context)
        {
            var privateLog = (PrivateLog)iq.Query;

            foreach (var item in privateLog.SelectElements <PrivateLogItem>())
            {
                archiveStore.SetMessageLogging(iq.From, item.Jid, item.Log);
                var to      = new Jid(item.Jid.Bare);
                var session = context.SessionManager.GetSession(to);
                if (session != null)
                {
                    var info = new IQ(IqType.set);
                    info.Id    = UniqueId.CreateNewId();
                    info.From  = iq.From;
                    info.To    = session.Jid;
                    info.Query = new PrivateLog();
                    info.Query.AddChild(new PrivateLogItem()
                    {
                        Jid = iq.From, Log = item.Log
                    });
                    context.Sender.SendTo(session, info);
                }
            }
            privateLog.RemoveAllChildNodes();

            iq.SwitchDirection();
            iq.Type = IqType.result;
            return(iq);
        }
        public void MessageLoggingTest()
        {
            var from = new Jid("jid1", "s", "R1");
            var to   = new Jid("jid2", "s", "R2");

            CheckGetLogging(from, to, true);

            store.SetMessageLogging(from, to, false);
            CheckGetLogging(from, to, false);

            store.SetMessageLogging(from, to, true);
            CheckGetLogging(from, to, true);

            store.SetMessageLogging(to, from, false);
            CheckGetLogging(from, to, false);

            store.SetMessageLogging(to, from, true);
            CheckGetLogging(from, to, true);
        }