decode URL manually
parent
29ff3aa5bb
commit
c4872bf14b
|
@ -19,7 +19,7 @@
|
|||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
ListView::ListView(irect *contentRect, const std::shared_ptr<vector<Item>> items) : _contentRect(contentRect), _items(items)
|
||||
ListView::ListView(const irect *contentRect, const std::shared_ptr<vector<Item>> items) : _contentRect(contentRect), _items(items)
|
||||
{
|
||||
FillAreaRect(_contentRect, WHITE);
|
||||
|
||||
|
@ -65,7 +65,7 @@ ListView::~ListView()
|
|||
void ListView::drawHeader(string headerText)
|
||||
{
|
||||
SetFont(_titleFont.get(), BLACK);
|
||||
headerText = Util::replaceString(headerText,"%20"," ");
|
||||
Util::decodeUrl(headerText);
|
||||
DrawTextRect(_contentRect->x, _contentRect->y, _contentRect->w, _headerHeight - 1, headerText.c_str(), ALIGN_LEFT);
|
||||
|
||||
int line = (_contentRect->y + _headerHeight) - 2;
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
* @param ContentRect area of the screen where the list view is placed
|
||||
* @param Items items that shall be shown in the listview
|
||||
*/
|
||||
ListView(irect *contentRect, const std::shared_ptr<vector<Item>> items);
|
||||
ListView(const irect *contentRect, const std::shared_ptr<vector<Item>> items);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
|
@ -66,7 +66,7 @@ public:
|
|||
int listClicked(int x, int y);
|
||||
|
||||
private:
|
||||
irect *_contentRect;
|
||||
const irect *_contentRect;
|
||||
const std::shared_ptr<vector<Item>> _items = nullptr;
|
||||
vector<ListViewEntry> _entries;
|
||||
std::unique_ptr<ifont> _titleFont;
|
||||
|
|
|
@ -17,7 +17,7 @@ using std::string;
|
|||
|
||||
LoginView *LoginView::_loginViewStatic;
|
||||
|
||||
LoginView::LoginView(irect *contentRect) : _contentRect(contentRect)
|
||||
LoginView::LoginView(const irect *contentRect) : _contentRect(contentRect)
|
||||
{
|
||||
_loginViewStatic = this;
|
||||
_loginFont = std::unique_ptr<ifont>(OpenFont("LiberationMono", 40, 1));
|
||||
|
|
|
@ -21,7 +21,7 @@ const int MAX_CHAR_BUFF_LENGHT = 256;
|
|||
class LoginView
|
||||
{
|
||||
public:
|
||||
LoginView(irect *contentRect);
|
||||
LoginView(const irect *contentRect);
|
||||
|
||||
int logginClicked(int x, int y);
|
||||
|
||||
|
@ -32,7 +32,7 @@ public:
|
|||
private:
|
||||
static LoginView *_loginViewStatic;
|
||||
std::unique_ptr<ifont> _loginFont;
|
||||
irect *_contentRect;
|
||||
const irect *_contentRect;
|
||||
irect _urlButton;
|
||||
irect _loginButton;
|
||||
irect _usernameButton;
|
||||
|
|
|
@ -50,7 +50,7 @@ Item::Item(const string &xmlItem)
|
|||
}
|
||||
|
||||
_title = _title.substr(_title.find_last_of("/") + 1, _title.length());
|
||||
_title = Util::replaceString(_title, "%20", " ");
|
||||
Util::decodeUrl(_title);
|
||||
}
|
||||
|
||||
void Item::open() const
|
||||
|
|
|
@ -73,12 +73,87 @@ string Util::getXMLAttribute(const string &buffer, const string &name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
string Util::replaceString(string item, const string& find, const string& to)
|
||||
void Util::decodeUrl(string &item)
|
||||
{
|
||||
for (size_t pos = item.find(find); pos != string::npos; pos = item.find(find, pos))
|
||||
string buffer;
|
||||
buffer.reserve(item.size());
|
||||
for (size_t pos = 0; pos != item.size(); ++pos)
|
||||
{
|
||||
item.replace(pos, find.length(), to);
|
||||
string temp = item.substr(pos, 3);
|
||||
if (temp == "%20")
|
||||
{
|
||||
buffer.append(" ");
|
||||
pos = pos + 2;
|
||||
}
|
||||
else if (temp == "%21")
|
||||
{
|
||||
buffer.append("!");
|
||||
pos = pos + 2;
|
||||
}
|
||||
else if (temp == "%22")
|
||||
{
|
||||
buffer.append("\"");
|
||||
pos = pos + 2;
|
||||
}
|
||||
else if (temp == "%23")
|
||||
{
|
||||
buffer.append("#");
|
||||
pos = pos + 2;
|
||||
}
|
||||
else if (temp == "%24")
|
||||
{
|
||||
buffer.append("$");
|
||||
pos = pos + 2;
|
||||
}
|
||||
else if (temp == "%25")
|
||||
{
|
||||
buffer.append("%");
|
||||
pos = pos + 2;
|
||||
}
|
||||
else if (temp == "%26")
|
||||
{
|
||||
buffer.append("&");
|
||||
pos = pos + 2;
|
||||
}
|
||||
else if (temp == "%27")
|
||||
{
|
||||
buffer.append("'");
|
||||
pos = pos + 2;
|
||||
}
|
||||
else if (temp == "%28")
|
||||
{
|
||||
buffer.append("(");
|
||||
pos = pos + 2;
|
||||
}
|
||||
else if (temp == "%29")
|
||||
{
|
||||
buffer.append(")");
|
||||
pos = pos + 2;
|
||||
}
|
||||
else if (temp == "%2a")
|
||||
{
|
||||
buffer.append("*");
|
||||
pos = pos + 2;
|
||||
}
|
||||
else if (temp == "%2b")
|
||||
{
|
||||
buffer.append("+");
|
||||
pos = pos + 2;
|
||||
}
|
||||
else if (temp == "%2c")
|
||||
{
|
||||
buffer.append(",");
|
||||
pos = pos + 2;
|
||||
}
|
||||
else if (temp == "%3f")
|
||||
{
|
||||
buffer.append("?");
|
||||
pos = pos + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.append(&item[pos], 1);
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
item.swap(buffer);
|
||||
}
|
|
@ -67,7 +67,7 @@ public:
|
|||
*/
|
||||
static string getXMLAttribute(const string &buffer, const string &name);
|
||||
|
||||
static string replaceString(string item, const string &find, const string &to);
|
||||
static void decodeUrl(string &item);
|
||||
|
||||
private:
|
||||
Util() {}
|
||||
|
|
Loading…
Reference in New Issue