source: smplayer/trunk/src/myserver.h@ 121

Last change on this file since 121 was 119, checked in by Silvan Scherrer, 14 years ago

SMPlayer: latest svn update

  • Property svn:eol-style set to LF
File size: 4.4 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2011 Ricardo Villalba <rvm@escomposlinux.org>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19#ifndef _MYSERVER_H_
20#define _MYSERVER_H_
21
22#include <QTcpServer>
23#include <QTcpSocket>
24#include <QStringList>
25
26//! Connection holds a connection from MyServer to a client.
27
28/*!
29 Connection objects are created by MyServer every time a new
30 connection is made.
31 It reads the text sent by the client, parses it, respond, and send
32 signals to the server to report client requests.
33 This class is for private use by MyServer.
34*/
35
36class Connection : public QObject
37{
38 Q_OBJECT
39
40public:
41 Connection(QTcpSocket * s);
42 ~Connection();
43
44 void setActionsList(QStringList l) { actions_list = l; };
45 QStringList actionsList() { return actions_list; };
46
47signals:
48 void receivedPlayItem(int);
49 void receivedRemoveItem(int);
50 void receivedMoveItem(int, int);
51 void receivedOpen(QString);
52 void receivedOpenFiles(QStringList);
53 void receivedAddFiles(QStringList);
54 void receivedFunction(QString);
55 void receivedLoadSubtitle(QString);
56 void receivedViewPlaylist(QString*);
57 void receivedViewStatus(QString*);
58 void receivedViewClipInfo(QString*);
59 void receivedSeek(double);
60 void receivedGetChecked(QString, QString*);
61 void receivedGetVolume(int*);
62 void receivedSetVolume(int);
63
64protected slots:
65 void readData();
66
67protected:
68 void sendText(QString l);
69 void parseLine(QString str);
70
71private:
72 QTcpSocket * socket;
73 QStringList actions_list;
74 QStringList files_to_open;
75};
76
77//! MyServer listens a port and waits for connections from other instances.
78
79/*!
80 MyServer will listen the specified port and will send signals
81 when another instance request something.
82*/
83
84class MyServer : public QTcpServer
85{
86 Q_OBJECT
87
88public:
89 MyServer( QObject * parent = 0 );
90
91 //! Tells the server to listen for incoming connections on port \a port.
92 bool listen( quint16 port );
93
94 //! Sets the list of actions.
95 //! The list is printed when the client requests it.
96 void setActionsList(QStringList l) { actions_list = l; };
97
98 //! Returns the list of actions.
99 QStringList actionsList() { return actions_list; };
100
101signals:
102 //! Emitted when the client requests that a certain file in the playlist is played.
103 void receivedPlayItem(int);
104
105 //! Emitted when the client requests that a certain file in the playlist is removed.
106 void receivedRemoveItem(int);
107
108 //! Emitted when the client requests that a certain file in the playlist is moved.
109 void receivedMoveItem(int, int);
110
111 //! Emitted when the client request to open a new file.
112 void receivedOpen(QString);
113
114 //! Emitted when the client request to open a list of files.
115 void receivedOpenFiles(QStringList);
116
117 //! Emitted when the client request to add a list of files to the playlist.
118 void receivedAddFiles(QStringList);
119
120 //! Emitted when the client request to perform an action.
121 void receivedFunction(QString);
122
123 //! Emitted when the client requests to load an external subtitle file.
124 void receivedLoadSubtitle(QString);
125
126 //! Emitted when the client requests the current playlist
127 //output is tab seperated, with each line containing filename, name, duration (sec)
128 void receivedViewPlaylist(QString*);
129
130 //! Emitted when the client requests the current status
131 void receivedViewStatus(QString*);
132
133 //! Emitted when the client requests a seek to the specified second
134 void receivedSeek(double);
135
136 //! Emitted when the client requests the clip info for the current track
137 void receivedViewClipInfo(QString*);
138
139 //! Emitted when the client request the state of a checkable action
140 void receivedGetChecked(QString, QString*);
141
142 //! Emitted when the client requests the current volume (be changed).
143 void receivedGetVolume(int*);
144 void receivedSetVolume(int);
145
146protected slots:
147 void newConnection_slot();
148
149private:
150 QStringList actions_list;
151};
152
153#endif
Note: See TracBrowser for help on using the repository browser.