~ubuntu-branches/ubuntu/raring/quassel/raring-proposed

« back to all changes in this revision

Viewing changes to src/core/coreircchannel.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-08-11 12:48:08 UTC
  • mfrom: (1.1.40 upstream)
  • Revision ID: james.westby@ubuntu.com-20100811124808-wl3zpp4gpbzmvn4t
Tags: 0.7~beta1-0ubuntu1
* New upstream beta release
  - Add libqca2-dev to build-depends for blowfish support
* Switch to source format v3 (Quilt) to use .bz2 tarball
  - Drop build-depends on quilt and update debian/rules
  - Add debian/source/format

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
 
 *   Copyright (C) 2005-09 by the Quassel Project                          *
 
2
 *   Copyright (C) 2005-2010 by the Quassel Project                        *
3
3
 *   devel@quassel-irc.org                                                 *
4
4
 *                                                                         *
5
5
 *   This program is free software; you can redistribute it and/or modify  *
19
19
 ***************************************************************************/
20
20
 
21
21
#include "coreircchannel.h"
 
22
#include "corenetwork.h"
22
23
 
23
24
INIT_SYNCABLE_OBJECT(CoreIrcChannel)
24
25
CoreIrcChannel::CoreIrcChannel(const QString &channelname, Network *network)
25
26
  : IrcChannel(channelname, network),
26
27
    _receivedWelcomeMsg(false)
27
28
{
28
 
}
 
29
#ifdef HAVE_QCA2
 
30
  _cipher = 0;
 
31
#endif
 
32
}
 
33
 
 
34
CoreIrcChannel::~CoreIrcChannel() {
 
35
#ifdef HAVE_QCA2
 
36
  delete _cipher;
 
37
#endif
 
38
}
 
39
 
 
40
#ifdef HAVE_QCA2
 
41
Cipher *CoreIrcChannel::cipher() const {
 
42
  if(!_cipher)
 
43
    _cipher = new Cipher();
 
44
 
 
45
  return _cipher;
 
46
}
 
47
 
 
48
void CoreIrcChannel::setEncrypted(bool e) {
 
49
  if(e) {
 
50
    if(topic().isEmpty())
 
51
      return;
 
52
 
 
53
    QByteArray key = qobject_cast<CoreNetwork *>(network())->cipherKey(name());
 
54
    if(key.isEmpty())
 
55
      return;
 
56
 
 
57
    if(!cipher()->setKey(key))
 
58
      return;
 
59
 
 
60
    QByteArray decrypted = cipher()->decryptTopic(topic().toAscii());
 
61
    setTopic(decodeString(decrypted));
 
62
  }
 
63
}
 
64
 
 
65
#endif