forked from Arora/arora
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a way to modify the user agent string from within the application.
- Loading branch information
Showing
13 changed files
with
401 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<RCC> | ||
<qresource prefix="/useragents" > | ||
<file>useragents.xml</file> | ||
</qresource> | ||
</RCC> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<useragentswitcher> | ||
<useragent description="Internet Explorer 6" useragent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" appcodename="Mozilla" appname="Microsoft Internet Explorer" appversion="4.0 (compatible; MSIE 6.0; Windows NT 5.1)" platform="Win32" vendor="" vendorsub=""/> | ||
<useragent description="Internet Explorer 7" useragent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)" appcodename="Mozilla" appname="Microsoft Internet Explorer" appversion="4.0 (compatible; MSIE 7.0; Windows NT 6.0)" platform="Win32" vendor="" vendorsub=""/> | ||
<useragent description="Internet Explorer 8" useragent="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)" appcodename="Mozilla" appname="Microsoft Internet Explorer" appversion="4.0 (compatible; MSIE 8.0; Windows NT 6.1)" platform="Win32" vendor="" vendorsub=""/> | ||
<useragent description="Googlebot 2.1" useragent="Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" appcodename="" appname="" appversion="" platform="" vendor="" vendorsub=""/> | ||
<useragent description="Msnbot 1.1" useragent="msnbot/1.1 (+http://search.msn.com/msnbot.htm)" appcodename="" appname="" appversion="" platform="" vendor="" vendorsub=""/> | ||
<useragent description="Yahoo Slurp" useragent="Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" appcodename="" appname="" appversion="" platform="" vendor="" vendorsub=""/> | ||
<useragent description="iPhone 3.0" useragent="Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16" appcodename="Mozilla" appname="Netscape" appversion="5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16" platform="iPhone" vendor="Apple Computer, Inc." vendorsub=""/> | ||
</useragentswitcher> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Copyright (c) 2010, William C. Witt | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. Neither the name of the Arora nor the names of its contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
|
||
#include "useragent.h" | ||
|
||
UserAgent::UserAgent() | ||
{ | ||
} | ||
|
||
UserAgent::UserAgent(const QString &name, const QString &userAgentString) | ||
{ | ||
this->name = name; | ||
this->userAgentString = userAgentString; | ||
} | ||
|
||
QString UserAgent::getName() | ||
{ | ||
return name; | ||
} | ||
|
||
void UserAgent::setName(const QString &name) | ||
{ | ||
this->name = name; | ||
} | ||
|
||
QString UserAgent::getUserAgentString() | ||
{ | ||
return userAgentString; | ||
} | ||
|
||
void UserAgent::setUserAgentString(const QString &userAgentString) | ||
{ | ||
this->userAgentString = userAgentString; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright (c) 2010, William C. Witt | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. Neither the name of the Arora nor the names of its contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef USERAGENT_H | ||
#define USERAGENT_H | ||
|
||
#include <qstring.h> | ||
|
||
class UserAgent | ||
{ | ||
public: | ||
UserAgent(); | ||
UserAgent(const QString &name, const QString &userAgentString); | ||
|
||
QString getName(); | ||
void setName(const QString &name); | ||
|
||
QString getUserAgentString(); | ||
void setUserAgentString(const QString &userAgentString); | ||
|
||
|
||
private: | ||
QString name; | ||
QString userAgentString; | ||
}; | ||
|
||
#endif // USERAGENT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
INCLUDEPATH += $$PWD | ||
DEPENDPATH += $$PWD | ||
|
||
HEADERS += \ | ||
useragent.h \ | ||
useragentmenu.h \ | ||
useragentmenuaction.h | ||
SOURCES += \ | ||
useragent.cpp \ | ||
useragentmenu.cpp \ | ||
useragentmenuaction.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** | ||
* Copyright (c) 2010, William C. Witt | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. Neither the name of the Arora nor the names of its contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
|
||
#include "useragentmenu.h" | ||
|
||
#include "useragentmenuaction.h" | ||
#include <QtXml> | ||
|
||
UserAgentMenu::UserAgentMenu(QWidget *parent) | ||
: QMenu(parent) | ||
{ | ||
buildUserAgentMenu(); | ||
} | ||
|
||
void UserAgentMenu::buildUserAgentMenu() | ||
{ | ||
DefaultUA *defaultUa = new DefaultUA(this); | ||
defaultUa->setText(tr("Default")); | ||
connect(defaultUa, SIGNAL(triggered()), defaultUa, SLOT(onAction())); | ||
addAction(defaultUa); | ||
|
||
addSeparator(); | ||
|
||
QDomDocument doc(tr("useragentswitcher")); | ||
QFile file(tr(":/useragents/useragents.xml")); | ||
if (!doc.setContent(&file)) { | ||
file.close(); | ||
} | ||
file.close(); | ||
QDomElement root = doc.documentElement(); | ||
QDomNode n = root.firstChild(); | ||
while (!n.isNull()) { | ||
QDomElement e = n.toElement(); | ||
if (!e.isNull()) { | ||
if (e.tagName() == tr("useragent")) { | ||
UserAgent ua(e.attribute(tr("description"), tr("")), e.attribute(tr("useragent"),tr(""))); | ||
UserAgentMenuAction *uama = new UserAgentMenuAction(this); | ||
uama->setUserAgent(ua); | ||
connect(uama, SIGNAL(triggered()), uama, SLOT(onAction())); | ||
addAction(uama); | ||
} | ||
} | ||
n = n.nextSibling(); | ||
} | ||
} | ||
|
||
|
||
DefaultUA::DefaultUA(QObject *parent) | ||
: QAction(parent) | ||
{ | ||
} | ||
|
||
void DefaultUA::onAction() | ||
{ | ||
QSettings setting; | ||
setting.remove(QLatin1String("useragent")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Copyright (c) 2010, William C. Witt | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. Neither the name of the Arora nor the names of its contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef USERAGENTMENU_H | ||
#define USERAGENTMENU_H | ||
|
||
#include <qmenu.h> | ||
|
||
class UserAgentMenu : public QMenu | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
UserAgentMenu(QWidget *parent = 0); | ||
void buildUserAgentMenu(); | ||
}; | ||
|
||
class DefaultUA : public QAction | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
DefaultUA(QObject *parent = 0); | ||
|
||
public slots: | ||
void onAction(); | ||
|
||
}; | ||
|
||
#endif // USERAGENTMENU_H |
Oops, something went wrong.