Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
594da3a3
Commit
594da3a3
authored
Oct 15, 2009
by
Daniel Molkentin
Browse files
CodePaster: Warn about empty hostname field instead of failing silently.
parent
ffb599da
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/cpaster/codepasterprotocol.cpp
View file @
594da3a3
...
...
@@ -62,10 +62,29 @@ bool CodePasterProtocol::canList() const
return
true
;
}
bool
CodePasterProtocol
::
isValidHostName
(
const
QString
&
hostName
)
{
if
(
hostName
.
isEmpty
())
{
ICore
::
instance
()
->
messageManager
()
->
printToOutputPane
(
#ifdef Q_OS_MAC
tr
(
"No Server defined in the CodePaster preferences!"
),
#else
tr
(
"No Server defined in the CodePaster options!"
),
#endif
true
/*error*/
);
ICore
::
instance
()
->
messageManager
()
->
showOutputPane
();
return
false
;
}
return
true
;
}
void
CodePasterProtocol
::
fetch
(
const
QString
&
id
)
{
QString
hostName
=
m_page
->
hostName
();
if
(
!
isValidHostName
(
hostName
))
return
;
QString
link
=
"http://"
;
link
.
append
(
m_page
->
hostName
()
);
link
.
append
(
hostName
);
link
.
append
(
"/?format=raw&id="
);
link
.
append
(
id
);
QUrl
url
(
link
);
...
...
@@ -78,9 +97,12 @@ void CodePasterProtocol::fetch(const QString &id)
void
CodePasterProtocol
::
list
(
QListWidget
*
listWidget
)
{
QString
hostName
=
m_page
->
hostName
();
if
(
!
isValidHostName
(
hostName
))
return
;
this
->
listWidget
=
listWidget
;
QString
link
=
QLatin1String
(
"http://"
);
link
+=
m_page
->
hostName
()
;
link
+=
hostName
;
link
+=
QLatin1String
(
"/?command=browse&format=raw"
);
QUrl
url
(
link
);
QNetworkRequest
r
(
url
);
...
...
@@ -93,6 +115,10 @@ void CodePasterProtocol::paste(const QString &text,
const
QString
&
comment
,
const
QString
&
description
)
{
QString
hostName
=
m_page
->
hostName
();
if
(
!
isValidHostName
(
hostName
))
return
;
QByteArray
data
=
"command=processcreate&submit=submit&highlight_type=0&description="
;
data
+=
CGI
::
encodeURL
(
description
).
toLatin1
();
data
+=
"&comment="
;
...
...
@@ -102,7 +128,7 @@ void CodePasterProtocol::paste(const QString &text,
data
+=
"&poster="
;
data
+=
CGI
::
encodeURL
(
username
).
toLatin1
();
http
.
setHost
(
m_page
->
hostName
()
);
http
.
setHost
(
hostName
);
http
.
post
(
"/"
,
data
);
}
...
...
src/plugins/cpaster/codepasterprotocol.h
View file @
594da3a3
...
...
@@ -66,6 +66,7 @@ public slots:
void
readPostResponseHeader
(
const
QHttpResponseHeader
&
);
private:
bool
isValidHostName
(
const
QString
&
hostName
);
CodePasterSettingsPage
*
m_page
;
QHttp
http
;
QNetworkAccessManager
manager
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment