~ubuntu-branches/ubuntu/trusty/smuxi/trusty-proposed

« back to all changes in this revision

Viewing changes to src/Frontend/ChatViewSyncManager.cs

  • Committer: Package Import Robot
  • Author(s): Mirco Bauer
  • Date: 2013-05-25 22:11:31 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20130525221131-nd2mc0kzubuwyx20
Tags: 0.8.11-1
* [22d13d5] Imported Upstream version 0.8.11
* [6d2b95a] Refreshed patches
* [89eb66e] Added ServiceStack libraries to smuxi-engine package
* [848ab10] Enable Campfire engine
* [c6dbdc7] Always build db4o for predictable build result
* [13ec489] Exclude OS X specific libraries from dh_clideps

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// Smuxi - Smart MUltipleXed Irc
2
2
//
3
 
// Copyright (c) 2011 Mirco Bauer <meebey@meebey.net>
 
3
// Copyright (c) 2011, 2013 Mirco Bauer <meebey@meebey.net>
4
4
//
5
5
// Full GPL License: <http://www.gnu.org/licenses/gpl.txt>
6
6
//
70
70
            IProtocolManager protocolManager = chatModel.ProtocolManager;
71
71
            Type protocolManagerType = null;
72
72
            if (protocolManager != null) {
73
 
                protocolManagerType = chatModel.ProtocolManager.GetType();
 
73
                protocolManagerType = protocolManager.GetType();
74
74
            }
75
75
#if LOG4NET
76
76
            DateTime stop = DateTime.UtcNow;
80
80
#endif
81
81
 
82
82
            OnChatAdded(chatModel, chatId, chatType, chatPosition,
83
 
                        protocolManagerType);
 
83
                        protocolManager, protocolManagerType);
 
84
        }
 
85
 
 
86
        /// <remarks>
 
87
        /// This method is thread safe.
 
88
        /// </remarks>
 
89
        public void Remove(ChatModel chatModel)
 
90
        {
 
91
            Trace.Call(chatModel);
 
92
 
 
93
            if (chatModel == null) {
 
94
                throw new ArgumentNullException("chatModel");
 
95
            }
 
96
 
 
97
            var chatKey = GetChatKey(chatModel);
 
98
#if LOG4NET
 
99
            Logger.DebugFormat("Remove() <{0}> removing from release queue",
 
100
                               chatKey);
 
101
#endif
 
102
            lock (SyncReleaseQueue) {
 
103
                SyncReleaseQueue.Remove(chatKey);
 
104
            }
84
105
        }
85
106
 
86
107
        public void Sync(IChatView chatView)
246
267
#endif
247
268
                        return;
248
269
                    }
 
270
                    // no longer need the release slot
 
271
                    // BUG: this breaks re-syncing an existing chat! For that
 
272
                    // reason the frontend _must_ notify us via Remove() if the
 
273
                    // chat sync state is no longer needed
 
274
                    //SyncReleaseQueue.Remove(chatKey);
249
275
                }
250
276
 
251
277
                Sync(chatView);
259
285
 
260
286
        void OnChatAdded(ChatModel chatModel, string chatId,
261
287
                         ChatType chatType, int chatPosition,
 
288
                         IProtocolManager protocolManager,
262
289
                         Type protocolManagerType)
263
290
        {
264
291
            if (ChatAdded != null) {
265
292
                ChatAdded(this,
266
293
                          new ChatViewAddedEventArgs(chatModel, chatId,
267
294
                                                     chatType, chatPosition,
 
295
                                                     protocolManager,
268
296
                                                     protocolManagerType));
269
297
            }
270
298
        }
293
321
        public string ChatID { get; private set; }
294
322
        public ChatType ChatType { get; private set; }
295
323
        public int ChatPosition { get; private set; }
 
324
        public IProtocolManager ProtocolManager { get; private set; }
296
325
        public Type ProtocolManagerType { get; private set; }
297
326
 
298
327
        public ChatViewAddedEventArgs(ChatModel chatModel, string chatId,
299
328
                                      ChatType chatType, int chatPosition,
 
329
                                      IProtocolManager protocolManager,
300
330
                                      Type protocolManagerType)
301
331
        {
302
332
            ChatModel = chatModel;
303
333
            ChatID = chatId;
304
334
            ChatType = chatType;
305
335
            ChatPosition = chatPosition;
 
336
            ProtocolManager = protocolManager;
306
337
            ProtocolManagerType = protocolManagerType;
307
338
        }
308
339
    }