File: server.cpp

package info (click to toggle)
psi-plugins 1.5-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,368 kB
  • sloc: cpp: 42,063; xml: 714; ansic: 84; makefile: 61; sh: 12
file content (112 lines) | stat: -rw-r--r-- 2,772 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 * server.cpp - plugin
 * Copyright (C) 2009-2011  Evgeny Khryukin
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */

#include "server.h"


Server::Server(QListWidget *parent)
	: QListWidgetItem(parent)	
	, displayName_("server")
	, url_("")
	, userName_("")
	, password_("")
	, servPostdata_("")
	, servFileinput_("")
	, servRegexp_("")
{
}

void Server::setDisplayName(QString n)
{
	displayName_ = n;
}

void Server::setServerData(const QString& post, const QString& fInput, const QString& reg/*, QString fFilter*/)
{
	servPostdata_ = post;
	servFileinput_ = fInput;
	servRegexp_ = reg;
	//servFilefilter_ = fFilter;
}

void Server::setServer(const QString& url, const QString& user, const QString& pass)
{
	url_ = url;
	userName_ = user;
	password_ = pass;
}

QString Server::settingsToString() const
{
	QStringList l = QStringList() << displayName_ << url_ << userName_ << password_;
	l << servPostdata_ << servFileinput_ << servRegexp_/* << servFilefilter_*/;
	l << (useProxy_ ? "true" : "false");
	return l.join(splitString());
}

void Server::setFromString(const QString& settings)
{
	QStringList l = settings.split(splitString());
	if(l.size() == 11) {
		processOltSettingsString(l);
		return;
	}
	if(!l.isEmpty())
		displayName_ = l.takeFirst();
	if(!l.isEmpty())
		url_ = l.takeFirst();
	if(!l.isEmpty())
		userName_ = l.takeFirst();
	if(!l.isEmpty())
		password_ = l.takeFirst();
	if(!l.isEmpty())
		servPostdata_ = l.takeFirst();
	if(!l.isEmpty())
		servFileinput_ = l.takeFirst();
	if(!l.isEmpty())
		servRegexp_ = l.takeFirst();
	/*if(!l.isEmpty())
		servFilefilter_ = l.takeFirst();*/
	if(!l.isEmpty())
		useProxy_ = (l.takeFirst() == "true");
}

void Server::processOltSettingsString(QStringList l)
{
	displayName_ = l.takeFirst();
	url_ = l.takeFirst();
	userName_ = l.takeFirst();
	password_ = l.takeFirst();

	//remove old useless proxy settings
	l.takeFirst();
	l.takeFirst();
	l.takeFirst();
	l.takeFirst();

	servPostdata_ = l.takeFirst();
	servFileinput_ = l.takeFirst();
	servRegexp_ = l.takeFirst();
}

QString Server::splitString()
{
	return QString("&split&");
}