~ubuntu-branches/ubuntu/saucy/kopete/saucy-proposed

« back to all changes in this revision

Viewing changes to plugins/pipes/pipesplugin.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-06-21 02:22:39 UTC
  • Revision ID: package-import@ubuntu.com-20130621022239-63l3zc8p0nf26pt6
Tags: upstream-4.10.80
ImportĀ upstreamĀ versionĀ 4.10.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    pipesplugin.h
 
3
 
 
4
    Copyright (c) 2007      by Charles Connell        <charles@connells.org>
 
5
 
 
6
    Kopete    (c) 2007      by the Kopete developers  <kopete-devel@kde.org>
 
7
 
 
8
    *************************************************************************
 
9
    *                                                                       *
 
10
    * This program is free software; you can redistribute it and/or modify  *
 
11
    * it under the terms of the GNU General Public License as published by  *
 
12
    * the Free Software Foundation; either version 2 of the License, or     *
 
13
    * (at your option) any later version.                                   *
 
14
    *                                                                       *
 
15
    *************************************************************************
 
16
*/
 
17
#ifndef PIPESPLUGIN_H
 
18
#define PIPESPLUGIN_H
 
19
 
 
20
#include "kopeteplugin.h"
 
21
 
 
22
#include <QUuid>
 
23
#include <QDomDocument>
 
24
#include <QVariantList>
 
25
 
 
26
namespace Kopete
 
27
{
 
28
        class SimpleMessageHandlerFactory;
 
29
        class Message;
 
30
}
 
31
 
 
32
/**
 
33
 * Core functions of Pipes plugin.
 
34
 * @author Charles Connell <charles@connells.org>
 
35
 */
 
36
 
 
37
class PipesPlugin : public Kopete::Plugin
 
38
{
 
39
                Q_OBJECT
 
40
 
 
41
        public:
 
42
                /*
 
43
                 * Used to indicate direction that a pipe is used for
 
44
                 */
 
45
                enum PipeDirection { Inbound = 0x1, Outbound = 0x2, BothDirections = Inbound | Outbound };
 
46
 
 
47
                /*
 
48
                 * Used to indicate what should be outputted, and what the input should be interpreted as
 
49
                 */
 
50
                enum PipeContents { HtmlBody = 0, PlainBody = 1, Xml = 2 };
 
51
 
 
52
                /*
 
53
                 * Stores everything we need to know about a pipe
 
54
                 */
 
55
                class PipeOptions
 
56
                {
 
57
                        public:
 
58
                                QUuid uid;
 
59
                                bool enabled;
 
60
                                QString path;
 
61
                                PipeDirection direction;
 
62
                                PipeContents pipeContents;
 
63
                };
 
64
                typedef QList<PipeOptions> PipeOptionsList;
 
65
 
 
66
        public:
 
67
                static PipesPlugin* plugin();
 
68
                
 
69
                PipesPlugin ( QObject *parent, const QVariantList &args );
 
70
                ~PipesPlugin();
 
71
 
 
72
        private slots:
 
73
                /*
 
74
                 * Grab incoming message, call doPiping for each
 
75
                 * appropriate pipe
 
76
                 */
 
77
                void slotIncomingMessage ( Kopete::Message & );
 
78
 
 
79
                /*
 
80
                 * Grab outgoing message, call doPiping for each
 
81
                 * appropriate pipe
 
82
                 */
 
83
                void slotOutgoingMessage ( Kopete::Message & );
 
84
 
 
85
        private:
 
86
                /*
 
87
                 * Fork process, push appropriate output to it,
 
88
                 * then read it's output and appropriately put it
 
89
                 * back in the message.
 
90
                 */
 
91
                static void doPiping ( Kopete::Message &, PipeOptions );
 
92
 
 
93
                /*
 
94
                 * Turn a Message into a QDomDocument, return that XML.
 
95
                 * Info for the XML is pulled from all over Kopete.
 
96
                 */
 
97
                static QByteArray createXml ( const Kopete::Message & );
 
98
 
 
99
                /*
 
100
                 * Take a QByteArray containing XML, take pertinent info from
 
101
                 * that, and put it in the Message.
 
102
                 */
 
103
                static void readXml ( PipeOptions, Kopete::Message &, const QByteArray & );
 
104
 
 
105
        private:
 
106
                static PipesPlugin* mPluginStatic;
 
107
                PipeOptionsList mPipesList;
 
108
                Kopete::SimpleMessageHandlerFactory * mInboundHandler;
 
109
 
 
110
};
 
111
 
 
112
Q_DECLARE_METATYPE ( PipesPlugin::PipeDirection )
 
113
Q_DECLARE_METATYPE ( PipesPlugin::PipeContents )
 
114
 
 
115
#endif