summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--data.cpp66
-rw-r--r--exclude.cpp4
-rw-r--r--gui/action.cpp36
-rw-r--r--gui/animation.cpp4
-rw-r--r--gui/console.cpp11
-rw-r--r--gui/fileselector.cpp4
-rw-r--r--gui/fill.cpp2
-rw-r--r--gui/gui.cpp16
-rw-r--r--gui/input.cpp4
-rw-r--r--gui/listbox.cpp4
-rw-r--r--gui/mousecursor.cpp26
-rw-r--r--gui/object.cpp6
-rw-r--r--gui/objects.hpp2
-rw-r--r--gui/pages.cpp22
-rw-r--r--gui/partitionlist.cpp8
-rw-r--r--gui/patternpassword.cpp82
-rw-r--r--gui/progressbar.cpp6
-rw-r--r--gui/resources.cpp8
-rw-r--r--gui/scrolllist.cpp12
-rw-r--r--gui/slider.cpp6
-rw-r--r--gui/slidervalue.cpp32
-rw-r--r--gui/terminal.cpp11
-rw-r--r--gui/textbox.cpp2
-rw-r--r--gui/theme/common/portrait.xml4
-rw-r--r--gui/twmsg.cpp2
-rw-r--r--openrecoveryscript.cpp10
-rw-r--r--partition.cpp2
-rw-r--r--partitionmanager.cpp10
-rw-r--r--twrp-functions.cpp56
-rw-r--r--twrp.cpp4
-rw-r--r--twrpTar.cpp14
-rw-r--r--twrpTar.h1
-rw-r--r--twrpTar.hpp1
33 files changed, 238 insertions, 240 deletions
diff --git a/data.cpp b/data.cpp
index eda23399a..65db77a2b 100644
--- a/data.cpp
+++ b/data.cpp
@@ -253,7 +253,7 @@ int DataManager::LoadValues(const string& filename)
pthread_mutex_unlock(&m_valuesLock);
string current = GetCurrentStoragePath();
TWPartition* Part = PartitionManager.Find_Partition_By_Path(current);
- if(!Part)
+ if (!Part)
Part = PartitionManager.Get_Default_Storage_Partition();
if (Part && current != Part->Storage_Path && Part->Mount(false)) {
LOGINFO("LoadValues setting storage path to '%s'\n", Part->Storage_Path.c_str());
@@ -536,7 +536,7 @@ void DataManager::SetDefaultValues()
mPersist.SetValue("tw_action_vibrate", "160");
TWPartition *store = PartitionManager.Get_Default_Storage_Partition();
- if(store)
+ if (store)
mPersist.SetValue("tw_storage_path", store->Storage_Path);
else
mPersist.SetValue("tw_storage_path", "/");
@@ -753,7 +753,7 @@ void DataManager::SetDefaultValues()
string maxbrightpath = findbright.insert(findbright.rfind('/') + 1, "max_");
if (TWFunc::Path_Exists(maxbrightpath)) {
ifstream maxVal(maxbrightpath.c_str());
- if(maxVal >> maxBrightness) {
+ if (maxVal >> maxBrightness) {
LOGINFO("Got max brightness %s from '%s'\n", maxBrightness.c_str(), maxbrightpath.c_str());
} else {
// Something went wrong, set that to indicate error
@@ -873,38 +873,38 @@ int DataManager::GetMagicValue(const string& varName, string& value)
}
else if (varName == "tw_cpu_temp")
{
- int tw_no_cpu_temp;
- GetValue("tw_no_cpu_temp", tw_no_cpu_temp);
- if (tw_no_cpu_temp == 1) return -1;
-
- string cpu_temp_file;
- static unsigned long convert_temp = 0;
- static time_t cpuSecCheck = 0;
- int divisor = 0;
- struct timeval curTime;
- string results;
-
- gettimeofday(&curTime, NULL);
- if (curTime.tv_sec > cpuSecCheck)
- {
+ int tw_no_cpu_temp;
+ GetValue("tw_no_cpu_temp", tw_no_cpu_temp);
+ if (tw_no_cpu_temp == 1) return -1;
+
+ string cpu_temp_file;
+ static unsigned long convert_temp = 0;
+ static time_t cpuSecCheck = 0;
+ int divisor = 0;
+ struct timeval curTime;
+ string results;
+
+ gettimeofday(&curTime, NULL);
+ if (curTime.tv_sec > cpuSecCheck)
+ {
#ifdef TW_CUSTOM_CPU_TEMP_PATH
- cpu_temp_file = EXPAND(TW_CUSTOM_CPU_TEMP_PATH);
- if (TWFunc::read_file(cpu_temp_file, results) != 0)
- return -1;
+ cpu_temp_file = EXPAND(TW_CUSTOM_CPU_TEMP_PATH);
+ if (TWFunc::read_file(cpu_temp_file, results) != 0)
+ return -1;
#else
- cpu_temp_file = "/sys/class/thermal/thermal_zone0/temp";
- if (TWFunc::read_file(cpu_temp_file, results) != 0)
- return -1;
+ cpu_temp_file = "/sys/class/thermal/thermal_zone0/temp";
+ if (TWFunc::read_file(cpu_temp_file, results) != 0)
+ return -1;
#endif
- convert_temp = strtoul(results.c_str(), NULL, 0) / 1000;
- if (convert_temp <= 0)
- convert_temp = strtoul(results.c_str(), NULL, 0);
- if (convert_temp >= 150)
- convert_temp = strtoul(results.c_str(), NULL, 0) / 10;
- cpuSecCheck = curTime.tv_sec + 5;
- }
- value = TWFunc::to_string(convert_temp);
- return 0;
+ convert_temp = strtoul(results.c_str(), NULL, 0) / 1000;
+ if (convert_temp <= 0)
+ convert_temp = strtoul(results.c_str(), NULL, 0);
+ if (convert_temp >= 150)
+ convert_temp = strtoul(results.c_str(), NULL, 0) / 10;
+ cpuSecCheck = curTime.tv_sec + 5;
+ }
+ value = TWFunc::to_string(convert_temp);
+ return 0;
}
else if (varName == "tw_battery")
{
@@ -924,7 +924,7 @@ int DataManager::GetMagicValue(const string& varName, string& value)
#else
FILE * cap = fopen("/sys/class/power_supply/battery/capacity","rt");
#endif
- if (cap){
+ if (cap) {
fgets(cap_s, 4, cap);
fclose(cap);
lastVal = atoi(cap_s);
diff --git a/exclude.cpp b/exclude.cpp
index 789c246e2..8ce138ad7 100644
--- a/exclude.cpp
+++ b/exclude.cpp
@@ -100,8 +100,8 @@ bool TWExclude::check_absolute_skip_dirs(const string& path) {
bool TWExclude::check_skip_dirs(const string& path) {
string normalized = TWFunc::Remove_Trailing_Slashes(path);
size_t slashIdx = normalized.find_last_of('/');
- if(slashIdx != std::string::npos && slashIdx+1 < normalized.size()) {
- if(check_relative_skip_dirs(normalized.substr(slashIdx+1)))
+ if (slashIdx != std::string::npos && slashIdx+1 < normalized.size()) {
+ if (check_relative_skip_dirs(normalized.substr(slashIdx+1)))
return true;
}
return check_absolute_skip_dirs(normalized);
diff --git a/gui/action.cpp b/gui/action.cpp
index 5ba749c81..8f85e16da 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -107,7 +107,7 @@ ActionThread::ActionThread()
ActionThread::~ActionThread()
{
pthread_mutex_lock(&m_act_lock);
- if(m_thread_running) {
+ if (m_thread_running) {
pthread_mutex_unlock(&m_act_lock);
pthread_join(m_thread, NULL);
} else {
@@ -262,7 +262,7 @@ GUIAction::GUIAction(xml_node<>* node)
if (attr)
{
std::vector<std::string> keys = TWFunc::Split_String(attr->value(), "+");
- for(size_t i = 0; i < keys.size(); ++i)
+ for (size_t i = 0; i < keys.size(); ++i)
{
const int key = getKeyByName(keys[i]);
mKeys[key] = false;
@@ -297,7 +297,7 @@ int GUIAction::NotifyTouch(TOUCH_STATE state, int x __unused, int y __unused)
int GUIAction::NotifyKey(int key, bool down)
{
std::map<int, bool>::iterator itr = mKeys.find(key);
- if(itr == mKeys.end())
+ if (itr == mKeys.end())
return 1;
bool prevState = itr->second;
@@ -307,20 +307,20 @@ int GUIAction::NotifyKey(int key, bool down)
// doesn't trigger with multi-key actions.
// Else, check if all buttons are pressed, then consume their release events
// so they don't trigger one-button actions and reset mKeys pressed status
- if(mKeys.size() == 1) {
- if(!down && prevState) {
+ if (mKeys.size() == 1) {
+ if (!down && prevState) {
doActions();
return 0;
}
- } else if(down) {
- for(itr = mKeys.begin(); itr != mKeys.end(); ++itr) {
- if(!itr->second)
+ } else if (down) {
+ for (itr = mKeys.begin(); itr != mKeys.end(); ++itr) {
+ if (!itr->second)
return 1;
}
// Passed, all req buttons are pressed, reset them and consume release events
HardwareKeyboard *kb = PageManager::GetHardwareKeyboard();
- for(itr = mKeys.begin(); itr != mKeys.end(); ++itr) {
+ for (itr = mKeys.begin(); itr != mKeys.end(); ++itr) {
kb->ConsumeKeyRelease(itr->first);
itr->second = false;
}
@@ -338,7 +338,7 @@ int GUIAction::NotifyVarChange(const std::string& varName, const std::string& va
if (varName.empty() && !isConditionValid() && mKeys.empty() && !mActionW)
doActions();
- else if((varName.empty() || IsConditionVariable(varName)) && isConditionValid() && isConditionTrue())
+ else if ((varName.empty() || IsConditionVariable(varName)) && isConditionValid() && isConditionTrue())
doActions();
return 0;
@@ -707,7 +707,7 @@ int GUIAction::compute(std::string arg)
int divide_by = atoi(divide_by_str.c_str());
int value;
- if(divide_by != 0)
+ if (divide_by != 0)
{
DataManager::GetValue(varName, value);
DataManager::SetValue(varName, value/divide_by);
@@ -855,7 +855,7 @@ int GUIAction::checkpartitionlist(std::string arg)
} else {
DataManager::SetValue("tw_check_partition_list", 0);
}
- return 0;
+ return 0;
}
int GUIAction::getpartitiondetails(std::string arg)
@@ -943,19 +943,19 @@ int GUIAction::screenshot(std::string arg __unused)
gid_t gid = -1;
struct passwd *pwd = getpwnam("media_rw");
- if(pwd) {
+ if (pwd) {
uid = pwd->pw_uid;
gid = pwd->pw_gid;
}
const std::string storage = DataManager::GetCurrentStoragePath();
- if(PartitionManager.Is_Mounted_By_Path(storage)) {
+ if (PartitionManager.Is_Mounted_By_Path(storage)) {
snprintf(path, sizeof(path), "%s/Pictures/Screenshots/", storage.c_str());
} else {
strcpy(path, "/tmp/");
}
- if(!TWFunc::Create_Dir_Recursive(path, 0775, uid, gid))
+ if (!TWFunc::Create_Dir_Recursive(path, 0775, uid, gid))
return 0;
tm = time(NULL);
@@ -965,7 +965,7 @@ int GUIAction::screenshot(std::string arg __unused)
strftime(path+path_len, sizeof(path)-path_len, "Screenshot_%Y-%m-%d-%H-%M-%S.png", localtime(&tm));
int res = gr_save_screenshot(path);
- if(res == 0) {
+ if (res == 0) {
chmod(path, 0666);
chown(path, uid, gid);
@@ -1388,7 +1388,7 @@ int GUIAction::terminalcommand(std::string arg)
struct timeval timeout;
fd_set fdset;
- while(keep_going)
+ while (keep_going)
{
FD_ZERO(&fdset);
FD_SET(fd, &fdset);
@@ -1406,7 +1406,7 @@ int GUIAction::terminalcommand(std::string arg)
keep_going = 0;
} else {
// Try to read output
- if(fgets(line, sizeof(line), fp) != NULL)
+ if (fgets(line, sizeof(line), fp) != NULL)
gui_print("%s", line); // Display output
else
keep_going = 0; // Done executing
diff --git a/gui/animation.cpp b/gui/animation.cpp
index d45373d81..37f0d0872 100644
--- a/gui/animation.cpp
+++ b/gui/animation.cpp
@@ -88,7 +88,7 @@ GUIAnimation::GUIAnimation(xml_node<>* node) : GUIObject(node)
int GUIAnimation::Render(void)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
if (!mAnimation || !mAnimation->GetResource(mFrame)) return -1;
@@ -99,7 +99,7 @@ int GUIAnimation::Render(void)
int GUIAnimation::Update(void)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
if (!mAnimation) return -1;
diff --git a/gui/console.cpp b/gui/console.cpp
index 6f375ff28..b518e77dc 100644
--- a/gui/console.cpp
+++ b/gui/console.cpp
@@ -78,7 +78,7 @@ extern "C" void __gui_print(const char *color, char *buf)
}
// The text after last \n (or whole string if there is no \n)
- if(*start) {
+ if (*start) {
gConsole.push_back(start);
gConsoleColor.push_back(color);
}
@@ -205,7 +205,10 @@ GUIConsole::GUIConsole(xml_node<>* node) : GUIScrollList(node)
if (!node)
{
- mRenderX = 0; mRenderY = 0; mRenderW = gr_fb_width(); mRenderH = gr_fb_height();
+ mRenderX = 0;
+ mRenderY = 0;
+ mRenderW = gr_fb_width();
+ mRenderH = gr_fb_height();
}
else
{
@@ -276,7 +279,7 @@ int GUIConsole::RenderConsole(void)
int GUIConsole::Render(void)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
if (mSlideout && mSlideoutState == hidden)
@@ -346,7 +349,7 @@ int GUIConsole::IsInRegion(int x, int y)
// Return 0 on success, >0 to ignore remainder of touch, and <0 on error
int GUIConsole::NotifyTouch(TOUCH_STATE state, int x, int y)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return -1;
if (mSlideout && x >= mSlideoutX && x < mSlideoutX + mSlideoutW && y >= mSlideoutY && y < mSlideoutY + mSlideoutH) {
diff --git a/gui/fileselector.cpp b/gui/fileselector.cpp
index 9275d976d..fa4ed8209 100644
--- a/gui/fileselector.cpp
+++ b/gui/fileselector.cpp
@@ -127,7 +127,7 @@ GUIFileSelector::~GUIFileSelector()
int GUIFileSelector::Update(void)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
GUIScrollList::Update();
@@ -155,7 +155,7 @@ int GUIFileSelector::NotifyVarChange(const std::string& varName, const std::stri
{
GUIScrollList::NotifyVarChange(varName, value);
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
if (varName.empty()) {
diff --git a/gui/fill.cpp b/gui/fill.cpp
index d0a1cfda7..0fda4b430 100644
--- a/gui/fill.cpp
+++ b/gui/fill.cpp
@@ -42,7 +42,7 @@ GUIFill::GUIFill(xml_node<>* node) : GUIObject(node)
int GUIFill::Render(void)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
gr_color(mColor.red, mColor.green, mColor.blue, mColor.alpha);
diff --git a/gui/gui.cpp b/gui/gui.cpp
index df41939fb..17ed108fc 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -300,15 +300,15 @@ void InputHandler::process_EV_KEY(input_event& ev)
// Handle key-press here
LOGEVENT("TOUCH_KEY: %d\n", ev.code);
// Left mouse button is treated as a touch
- if(ev.code == BTN_LEFT)
+ if (ev.code == BTN_LEFT)
{
MouseCursor *cursor = PageManager::GetMouseCursor();
- if(ev.value == 1)
+ if (ev.value == 1)
{
cursor->GetPos(x, y);
doTouchStart();
}
- else if(touch_status)
+ else if (touch_status)
{
// Left mouse button was previously pressed and now is
// being released so send a TOUCH_RELEASE
@@ -323,9 +323,9 @@ void InputHandler::process_EV_KEY(input_event& ev)
}
}
// side mouse button, often used for "back" function
- else if(ev.code == BTN_SIDE)
+ else if (ev.code == BTN_SIDE)
{
- if(ev.value == 1)
+ if (ev.value == 1)
kb->KeyDown(KEY_BACK);
else
kb->KeyUp(KEY_BACK);
@@ -366,12 +366,12 @@ void InputHandler::process_EV_REL(input_event& ev)
// Mouse movement
MouseCursor *cursor = PageManager::GetMouseCursor();
LOGEVENT("EV_REL %d %d\n", ev.code, ev.value);
- if(ev.code == REL_X)
+ if (ev.code == REL_X)
cursor->Move(ev.value, 0);
- else if(ev.code == REL_Y)
+ else if (ev.code == REL_Y)
cursor->Move(0, ev.value);
- if(touch_status) {
+ if (touch_status) {
cursor->GetPos(x, y);
LOGEVENT("Mouse TOUCH_DRAG: %d, %d\n", x, y);
key_status = KS_NONE;
diff --git a/gui/input.cpp b/gui/input.cpp
index ec370abe5..8dd981c24 100644
--- a/gui/input.cpp
+++ b/gui/input.cpp
@@ -236,7 +236,7 @@ void GUIInput::HandleCursorByTouch(int x) {
unsigned index = 0, displaySize = displayValue.size();
int prevX = mRenderX + scrollingX;
- for(index = 0; index <= displaySize; index++) {
+ for (index = 0; index <= displaySize; index++) {
cursorString = displayValue.substr(0, index);
cursorX = gr_ttf_measureEx(cursorString.c_str(), fontResource) + mRenderX + scrollingX;
if (cursorX > x) {
@@ -263,7 +263,7 @@ void GUIInput::HandleCursorByTouch(int x) {
}
void GUIInput::HandleCursorByText() {
-// Uses mCursorLocation to find cursorX
+// Uses mCursorLocation to find cursorX
if (!DrawCursor)
return;
diff --git a/gui/listbox.cpp b/gui/listbox.cpp
index e10fee72a..05276e8ac 100644
--- a/gui/listbox.cpp
+++ b/gui/listbox.cpp
@@ -123,7 +123,7 @@ GUIListBox::~GUIListBox()
int GUIListBox::Update(void)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
GUIScrollList::Update();
@@ -140,7 +140,7 @@ int GUIListBox::NotifyVarChange(const std::string& varName, const std::string& v
{
GUIScrollList::NotifyVarChange(varName, value);
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
// Check to see if the variable that we are using to store the list selected value has been updated
diff --git a/gui/mousecursor.cpp b/gui/mousecursor.cpp
index bd730df6b..cb5e11b75 100644
--- a/gui/mousecursor.cpp
+++ b/gui/mousecursor.cpp
@@ -52,15 +52,15 @@ void MouseCursor::LoadData(xml_node<>* node)
xml_node<>* child;
child = FindNode(node, "placement");
- if(child)
+ if (child)
LoadPlacement(child, &mRenderX, &mRenderY, &mRenderW, &mRenderH);
child = FindNode(node, "background");
- if(child)
+ if (child)
{
m_color = LoadAttrColor(child, "color", m_color);
m_image = LoadAttrImage(child, "resource");
- if(m_image)
+ if (m_image)
{
mRenderW = m_image->GetWidth();
mRenderH = m_image->GetHeight();
@@ -68,20 +68,20 @@ void MouseCursor::LoadData(xml_node<>* node)
}
child = FindNode(node, "speed");
- if(child)
+ if (child)
{
attr = child->first_attribute("multiplier");
- if(attr)
+ if (attr)
m_speedMultiplier = atof(attr->value());
}
}
int MouseCursor::Render(void)
{
- if(!m_present)
+ if (!m_present)
return 0;
- if(m_image)
+ if (m_image)
{
gr_blit(m_image->GetResource(), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY);
}
@@ -95,15 +95,15 @@ int MouseCursor::Render(void)
int MouseCursor::Update(void)
{
- if(m_present != ev_has_mouse())
+ if (m_present != ev_has_mouse())
{
m_present = ev_has_mouse();
- if(m_present)
+ if (m_present)
SetRenderPos(m_resX/2, m_resY/2);
return 2;
}
- if(m_present && m_moved)
+ if (m_present && m_moved)
{
m_moved = false;
return 2;
@@ -113,7 +113,7 @@ int MouseCursor::Update(void)
int MouseCursor::SetRenderPos(int x, int y, int w, int h)
{
- if(x == mRenderX && y == mRenderY)
+ if (x == mRenderX && y == mRenderY)
m_moved = true;
return RenderObject::SetRenderPos(x, y, w, h);
@@ -121,7 +121,7 @@ int MouseCursor::SetRenderPos(int x, int y, int w, int h)
void MouseCursor::Move(int deltaX, int deltaY)
{
- if(deltaX != 0)
+ if (deltaX != 0)
{
mRenderX += deltaX*m_speedMultiplier;
mRenderX = (std::min)(mRenderX, m_resX);
@@ -130,7 +130,7 @@ void MouseCursor::Move(int deltaX, int deltaY)
m_moved = true;
}
- if(deltaY != 0)
+ if (deltaY != 0)
{
mRenderY += deltaY*m_speedMultiplier;
mRenderY = (std::min)(mRenderY, m_resY);
diff --git a/gui/object.cpp b/gui/object.cpp
index e7d1bf99b..be831a778 100644
--- a/gui/object.cpp
+++ b/gui/object.cpp
@@ -159,7 +159,7 @@ bool GUIObject::UpdateConditions(std::vector<Condition>& conditions, const std::
std::vector<Condition>::iterator iter;
for (iter = conditions.begin(); iter != conditions.end(); ++iter)
{
- if(varNameEmpty && iter->mCompareOp == "modified")
+ if (varNameEmpty && iter->mCompareOp == "modified")
{
string val;
@@ -172,10 +172,10 @@ bool GUIObject::UpdateConditions(std::vector<Condition>& conditions, const std::
iter->mLastVal = val;
}
- if(varNameEmpty || iter->mVar1 == varName || iter->mVar2 == varName)
+ if (varNameEmpty || iter->mVar1 == varName || iter->mVar2 == varName)
iter->mLastResult = isConditionTrue(&(*iter));
- if(!iter->mLastResult)
+ if (!iter->mLastResult)
result = false;
}
return result;
diff --git a/gui/objects.hpp b/gui/objects.hpp
index 750627729..f1c9c49dd 100644
--- a/gui/objects.hpp
+++ b/gui/objects.hpp
@@ -1234,8 +1234,6 @@ COLOR LoadAttrColor(xml_node<>* element, const char* attrname, COLOR defaultvalu
FontResource* LoadAttrFont(xml_node<>* element, const char* attrname);
ImageResource* LoadAttrImage(xml_node<>* element, const char* attrname);
AnimationResource* LoadAttrAnimation(xml_node<>* element, const char* attrname);
-
bool LoadPlacement(xml_node<>* node, int* x, int* y, int* w = NULL, int* h = NULL, Placement* placement = NULL);
#endif // _OBJECTS_HEADER
-
diff --git a/gui/pages.cpp b/gui/pages.cpp
index d7cb92d63..5c647c334 100644
--- a/gui/pages.cpp
+++ b/gui/pages.cpp
@@ -1009,7 +1009,7 @@ int PageSet::LoadVariables(xml_node<>* vars)
name = child->first_attribute("name");
value = child->first_attribute("value");
persist = child->first_attribute("persist");
- if(name && value)
+ if (name && value)
{
if (strcmp(name->value(), "tw_x_offset") == 0) {
tw_x_offset = atoi(value->value());
@@ -1193,7 +1193,7 @@ char* PageManager::LoadFileToBuffer(std::string filename, ZipArchive* package) {
// We can try to load the XML directly...
LOGINFO("PageManager::LoadFileToBuffer loading filename: '%s' directly\n", filename.c_str());
struct stat st;
- if(stat(filename.c_str(),&st) != 0) {
+ if (stat(filename.c_str(),&st) != 0) {
// This isn't always an error, sometimes we request files that don't exist.
return NULL;
}
@@ -1471,7 +1471,7 @@ int PageManager::ReloadPackage(std::string name, std::string package)
if (iter == mPageSets.end())
return -1;
- if(mMouseCursor)
+ if (mMouseCursor)
mMouseCursor->ResetData(gr_fb_width(), gr_fb_height());
PageSet* set = (*iter).second;
@@ -1589,18 +1589,18 @@ int PageManager::IsCurrentPage(Page* page)
int PageManager::Render(void)
{
- if(blankTimer.isScreenOff())
+ if (blankTimer.isScreenOff())
return 0;
int res = (mCurrentSet ? mCurrentSet->Render() : -1);
- if(mMouseCursor)
+ if (mMouseCursor)
mMouseCursor->Render();
return res;
}
HardwareKeyboard *PageManager::GetHardwareKeyboard()
{
- if(!mHardwareKeyboard)
+ if (!mHardwareKeyboard)
mHardwareKeyboard = new HardwareKeyboard();
return mHardwareKeyboard;
}
@@ -1630,14 +1630,14 @@ xml_node<>* PageManager::FindStyle(std::string name)
MouseCursor *PageManager::GetMouseCursor()
{
- if(!mMouseCursor)
+ if (!mMouseCursor)
mMouseCursor = new MouseCursor(gr_fb_width(), gr_fb_height());
return mMouseCursor;
}
void PageManager::LoadCursorData(xml_node<>* node)
{
- if(!mMouseCursor)
+ if (!mMouseCursor)
mMouseCursor = new MouseCursor(gr_fb_width(), gr_fb_height());
mMouseCursor->LoadData(node);
@@ -1645,7 +1645,7 @@ void PageManager::LoadCursorData(xml_node<>* node)
int PageManager::Update(void)
{
- if(blankTimer.isScreenOff())
+ if (blankTimer.isScreenOff())
return 0;
if (RunReload())
@@ -1653,10 +1653,10 @@ int PageManager::Update(void)
int res = (mCurrentSet ? mCurrentSet->Update() : -1);
- if(mMouseCursor)
+ if (mMouseCursor)
{
int c_res = mMouseCursor->Update();
- if(c_res > res)
+ if (c_res > res)
res = c_res;
}
return res;
diff --git a/gui/partitionlist.cpp b/gui/partitionlist.cpp
index ff207fa9a..dca390448 100644
--- a/gui/partitionlist.cpp
+++ b/gui/partitionlist.cpp
@@ -79,7 +79,7 @@ GUIPartitionList::~GUIPartitionList()
int GUIPartitionList::Update(void)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
// Check for changes in mount points if the list type is mount and update the list and render if needed
@@ -101,8 +101,8 @@ int GUIPartitionList::Update(void)
if (updateList) {
int listSize = 0;
- // Completely update the list if needed -- Used primarily for
- // restore as the list for restore will change depending on what
+ // Completely update the list if needed -- Used primarily for
+ // restore as the list for restore will change depending on what
// partitions were backed up
mList.clear();
PartitionManager.Get_Partition_List(ListType, &mList);
@@ -126,7 +126,7 @@ int GUIPartitionList::NotifyVarChange(const std::string& varName, const std::str
{
GUIScrollList::NotifyVarChange(varName, value);
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
if (varName == mVariable && !mUpdate)
diff --git a/gui/patternpassword.cpp b/gui/patternpassword.cpp
index ab446b9f0..4bce37a0c 100644
--- a/gui/patternpassword.cpp
+++ b/gui/patternpassword.cpp
@@ -54,7 +54,7 @@ GUIPatternPassword::GUIPatternPassword(xml_node<>* node)
mAction = new GUIAction(node);
child = FindNode(node, "dot");
- if(child)
+ if (child)
{
mDotColor = LoadAttrColor(child, "color", mDotColor);
mActiveDotColor = LoadAttrColor(child, "activecolor", mActiveDotColor);
@@ -65,18 +65,18 @@ GUIPatternPassword::GUIPatternPassword(xml_node<>* node)
}
child = FindNode(node, "line");
- if(child)
+ if (child)
{
mLineColor = LoadAttrColor(child, "color", mLineColor);
mLineWidth = LoadAttrIntScaleX(child, "width", mLineWidth);
}
child = FindNode(node, "data");
- if(child)
+ if (child)
mPassVar = LoadAttrString(child, "name", "");
child = FindNode(node, "size");
- if(child) {
+ if (child) {
mSizeVar = LoadAttrString(child, "name", "");
// Use the configured default, if set.
@@ -84,7 +84,7 @@ GUIPatternPassword::GUIPatternPassword(xml_node<>* node)
Resize(size);
}
- if(!mDotImage || !mDotImage->GetResource() || !mActiveDotImage || !mActiveDotImage->GetResource())
+ if (!mDotImage || !mDotImage->GetResource() || !mActiveDotImage || !mActiveDotImage->GetResource())
{
mDotCircle = gr_render_circle(mDotRadius, mDotColor.red, mDotColor.green, mDotColor.blue, mDotColor.alpha);
mActiveDotCircle = gr_render_circle(mDotRadius/2, mActiveDotColor.red, mActiveDotColor.green, mActiveDotColor.blue, mActiveDotColor.alpha);
@@ -104,10 +104,10 @@ GUIPatternPassword::~GUIPatternPassword()
delete[] mDots;
delete[] mConnectedDots;
- if(mDotCircle)
+ if (mDotCircle)
gr_free_surface(mDotCircle);
- if(mActiveDotCircle)
+ if (mActiveDotCircle)
gr_free_surface(mActiveDotCircle);
}
@@ -115,7 +115,7 @@ void GUIPatternPassword::ResetActiveDots()
{
mConnectedDotsLen = 0;
mCurLineX = mCurLineY = -1;
- for(size_t i = 0; i < mGridSize * mGridSize; ++i)
+ for (size_t i = 0; i < mGridSize * mGridSize; ++i)
mDots[i].active = false;
}
@@ -155,9 +155,9 @@ void GUIPatternPassword::CalculateDotPositions(void)
* n*n-1
*/
- for(size_t r = 0; r < mGridSize; ++r)
+ for (size_t r = 0; r < mGridSize; ++r)
{
- for(size_t c = 0; c < mGridSize; ++c)
+ for (size_t c = 0; c < mGridSize; ++c)
{
mDots[mGridSize*r + c].x = x;
mDots[mGridSize*r + c].y = y;
@@ -170,29 +170,29 @@ void GUIPatternPassword::CalculateDotPositions(void)
int GUIPatternPassword::Render(void)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
gr_color(mLineColor.red, mLineColor.green, mLineColor.blue, mLineColor.alpha);
- for(size_t i = 1; i < mConnectedDotsLen; ++i) {
+ for (size_t i = 1; i < mConnectedDotsLen; ++i) {
const Dot& dp = mDots[mConnectedDots[i-1]];
const Dot& dc = mDots[mConnectedDots[i]];
gr_line(dp.x + mDotRadius, dp.y + mDotRadius, dc.x + mDotRadius, dc.y + mDotRadius, mLineWidth);
}
- if(mConnectedDotsLen > 0 && mTrackingTouch) {
+ if (mConnectedDotsLen > 0 && mTrackingTouch) {
const Dot& dc = mDots[mConnectedDots[mConnectedDotsLen-1]];
gr_line(dc.x + mDotRadius, dc.y + mDotRadius, mCurLineX, mCurLineY, mLineWidth);
}
- for(size_t i = 0; i < mGridSize * mGridSize; ++i) {
- if(mDotCircle) {
+ for (size_t i = 0; i < mGridSize * mGridSize; ++i) {
+ if (mDotCircle) {
gr_blit(mDotCircle, 0, 0, gr_get_width(mDotCircle), gr_get_height(mDotCircle), mDots[i].x, mDots[i].y);
- if(mDots[i].active) {
+ if (mDots[i].active) {
gr_blit(mActiveDotCircle, 0, 0, gr_get_width(mActiveDotCircle), gr_get_height(mActiveDotCircle), mDots[i].x + mDotRadius/2, mDots[i].y + mDotRadius/2);
}
} else {
- if(mDots[i].active) {
+ if (mDots[i].active) {
gr_blit(mActiveDotImage->GetResource(), 0, 0, mActiveDotImage->GetWidth(), mActiveDotImage->GetHeight(),
mDots[i].x + (mDotRadius - mActiveDotImage->GetWidth()/2), mDots[i].y + (mDotRadius - mActiveDotImage->GetHeight()/2));
} else {
@@ -205,7 +205,7 @@ int GUIPatternPassword::Render(void)
int GUIPatternPassword::Update(void)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
int res = mNeedRender ? 2 : 1;
@@ -214,7 +214,7 @@ int GUIPatternPassword::Update(void)
}
void GUIPatternPassword::Resize(size_t n) {
- if(mGridSize == n)
+ if (mGridSize == n)
return;
delete[] mDots;
@@ -247,8 +247,8 @@ static bool IsInCircle(int x, int y, int ox, int oy, int r)
int GUIPatternPassword::InDot(int x, int y)
{
- for(size_t i = 0; i < mGridSize * mGridSize; ++i) {
- if(IsInCircle(x, y, mDots[i].x + mDotRadius, mDots[i].y + mDotRadius, mDotRadius*3))
+ for (size_t i = 0; i < mGridSize * mGridSize; ++i) {
+ if (IsInCircle(x, y, mDots[i].x + mDotRadius, mDots[i].y + mDotRadius, mDotRadius*3))
return i;
}
return -1;
@@ -256,8 +256,8 @@ int GUIPatternPassword::InDot(int x, int y)
bool GUIPatternPassword::DotUsed(int dot_idx)
{
- for(size_t i = 0; i < mConnectedDotsLen; ++i) {
- if(mConnectedDots[i] == dot_idx)
+ for (size_t i = 0; i < mConnectedDotsLen; ++i) {
+ if (mConnectedDots[i] == dot_idx)
return true;
}
return false;
@@ -265,7 +265,7 @@ bool GUIPatternPassword::DotUsed(int dot_idx)
void GUIPatternPassword::ConnectDot(int dot_idx)
{
- if(mConnectedDotsLen >= mGridSize * mGridSize)
+ if (mConnectedDotsLen >= mGridSize * mGridSize)
{
LOGERR("mConnectedDots in GUIPatternPassword has overflown!\n");
return;
@@ -277,7 +277,7 @@ void GUIPatternPassword::ConnectDot(int dot_idx)
void GUIPatternPassword::ConnectIntermediateDots(int next_dot_idx)
{
- if(mConnectedDotsLen == 0)
+ if (mConnectedDotsLen == 0)
return;
const int prev_dot_idx = mConnectedDots[mConnectedDotsLen-1];
@@ -311,15 +311,15 @@ void GUIPatternPassword::ConnectIntermediateDots(int next_dot_idx)
int Dy = (ny > py) ? 1 : -1;
// Vertical lines.
- if(px == nx)
+ if (px == nx)
Dx = 0;
// Horizontal lines.
- else if(py == ny)
+ else if (py == ny)
Dy = 0;
// Diagonal lines (|∆x| = |∆y|).
- else if(abs(px - nx) == abs(py - ny))
+ else if (abs(px - nx) == abs(py - ny))
;
// No valid intermediate dots.
@@ -327,19 +327,19 @@ void GUIPatternPassword::ConnectIntermediateDots(int next_dot_idx)
return;
// Iterate along axis, adding dots in the correct order.
- while((Dy == 0 || y != ny - Dy) && (Dx == 0 || x != nx - Dx)) {
+ while ((Dy == 0 || y != ny - Dy) && (Dx == 0 || x != nx - Dx)) {
x += Dx;
y += Dy;
int idx = mGridSize * y + x;
- if(!DotUsed(idx))
+ if (!DotUsed(idx))
ConnectDot(idx);
}
}
int GUIPatternPassword::NotifyTouch(TOUCH_STATE state, int x, int y)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return -1;
switch (state)
@@ -347,7 +347,7 @@ int GUIPatternPassword::NotifyTouch(TOUCH_STATE state, int x, int y)
case TOUCH_START:
{
const int dot_idx = InDot(x, y);
- if(dot_idx == -1)
+ if (dot_idx == -1)
break;
mTrackingTouch = true;
@@ -361,11 +361,11 @@ int GUIPatternPassword::NotifyTouch(TOUCH_STATE state, int x, int y)
}
case TOUCH_DRAG:
{
- if(!mTrackingTouch)
+ if (!mTrackingTouch)
break;
const int dot_idx = InDot(x, y);
- if(dot_idx != -1 && !DotUsed(dot_idx))
+ if (dot_idx != -1 && !DotUsed(dot_idx))
{
ConnectIntermediateDots(dot_idx);
ConnectDot(dot_idx);
@@ -379,7 +379,7 @@ int GUIPatternPassword::NotifyTouch(TOUCH_STATE state, int x, int y)
}
case TOUCH_RELEASE:
{
- if(!mTrackingTouch)
+ if (!mTrackingTouch)
break;
mNeedRender = true;
@@ -396,10 +396,10 @@ int GUIPatternPassword::NotifyTouch(TOUCH_STATE state, int x, int y)
int GUIPatternPassword::NotifyVarChange(const std::string& varName, const std::string& value)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
- if(varName == mSizeVar) {
+ if (varName == mSizeVar) {
Resize(atoi(value.c_str()));
mUpdate = true;
}
@@ -420,8 +420,8 @@ static unsigned int getSDKVersion(void) {
std::string GUIPatternPassword::GeneratePassphrase()
{
char pattern[mConnectedDotsLen];
- for(size_t i = 0; i < mConnectedDotsLen; i++) {
- pattern[i] = (char) mConnectedDots[i];
+ for (size_t i = 0; i < mConnectedDotsLen; i++) {
+ pattern[i] = (char) mConnectedDots[i];
}
std::stringstream pass;
@@ -461,9 +461,9 @@ std::string GUIPatternPassword::GeneratePassphrase()
void GUIPatternPassword::PatternDrawn()
{
- if(!mPassVar.empty() && mConnectedDotsLen > 0)
+ if (!mPassVar.empty() && mConnectedDotsLen > 0)
DataManager::SetValue(mPassVar, GeneratePassphrase());
- if(mAction)
+ if (mAction)
mAction->doActions();
}
diff --git a/gui/progressbar.cpp b/gui/progressbar.cpp
index fc2a4976c..c40e63ea2 100644
--- a/gui/progressbar.cpp
+++ b/gui/progressbar.cpp
@@ -67,7 +67,7 @@ GUIProgressBar::GUIProgressBar(xml_node<>* node) : GUIObject(node)
int GUIProgressBar::Render(void)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
// This handles making sure timing updates occur
@@ -90,7 +90,7 @@ int GUIProgressBar::RenderInternal(void)
int GUIProgressBar::Update(void)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
std::string str;
@@ -165,7 +165,7 @@ int GUIProgressBar::NotifyVarChange(const std::string& varName, const std::strin
{
GUIObject::NotifyVarChange(varName, value);
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
static int nextPush = 0;
diff --git a/gui/resources.cpp b/gui/resources.cpp
index 8884dd796..000912d4e 100644
--- a/gui/resources.cpp
+++ b/gui/resources.cpp
@@ -124,7 +124,7 @@ void FontResource::LoadFont(xml_node<>* node, ZipArchive* pZip)
file = attr->value();
- if(file.size() >= 4 && file.compare(file.size()-4, 4, ".ttf") == 0)
+ if (file.size() >= 4 && file.compare(file.size()-4, 4, ".ttf") == 0)
{
int font_size = 0;
@@ -144,7 +144,7 @@ void FontResource::LoadFont(xml_node<>* node, ZipArchive* pZip)
int dpi = 300;
attr = node->first_attribute("dpi");
- if(attr)
+ if (attr)
dpi = atoi(attr->value());
// we can't use TMP_RESOURCE_NAME here because the ttf subsystem is caching the name and scaling needs to reload the font
@@ -166,10 +166,10 @@ void FontResource::LoadFont(xml_node<>* node, ZipArchive* pZip)
}
void FontResource::DeleteFont() {
- if(mFont)
+ if (mFont)
gr_ttf_freeFont(mFont);
mFont = NULL;
- if(origFont)
+ if (origFont)
gr_ttf_freeFont(origFont);
origFont = NULL;
}
diff --git a/gui/scrolllist.cpp b/gui/scrolllist.cpp
index 291b3820b..7540356bf 100644
--- a/gui/scrolllist.cpp
+++ b/gui/scrolllist.cpp
@@ -190,7 +190,7 @@ void GUIScrollList::SetVisibleListLocation(size_t list_index)
int GUIScrollList::Render(void)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
// First step, fill background
@@ -352,7 +352,7 @@ void GUIScrollList::RenderStdItem(int yPos, bool selected, ImageResource* icon,
int GUIScrollList::Update(void)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
if (!mHeaderIsStatic) {
@@ -421,7 +421,7 @@ size_t GUIScrollList::HitTestItem(int x __unused, int y)
int GUIScrollList::NotifyTouch(TOUCH_STATE state, int x, int y)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return -1;
switch (state)
@@ -524,7 +524,7 @@ void GUIScrollList::HandleScrolling()
{
// handle dragging downward, scrolling upward
// the offset should always be <= 0 and > -actualItemHeight, adjust the first display row and offset as needed
- while(firstDisplayedItem && y_offset > 0) {
+ while (firstDisplayedItem && y_offset > 0) {
firstDisplayedItem--;
y_offset -= actualItemHeight;
}
@@ -569,7 +569,7 @@ int GUIScrollList::NotifyVarChange(const std::string& varName, const std::string
{
GUIObject::NotifyVarChange(varName, value);
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
if (!mHeaderIsStatic) {
@@ -624,7 +624,7 @@ bool GUIScrollList::AddLines(std::vector<std::string>* origText, std::vector<std
string curr_color;
if (origColor)
curr_color = origColor->at(i);
- for(;;) {
+ for (;;) {
size_t line_char_width = gr_ttf_maxExW(curr_line.c_str(), mFont->GetResource(), mRenderW);
if (line_char_width < curr_line.size()) {
//string left = curr_line.substr(0, line_char_width);
diff --git a/gui/slider.cpp b/gui/slider.cpp
index 59b295bd0..1a2f59e68 100644
--- a/gui/slider.cpp
+++ b/gui/slider.cpp
@@ -108,7 +108,7 @@ GUISlider::~GUISlider()
int GUISlider::Render(void)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
if (!sSlider || !sSlider->GetResource())
@@ -136,7 +136,7 @@ int GUISlider::Render(void)
int GUISlider::Update(void)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
if (sUpdate)
@@ -146,7 +146,7 @@ int GUISlider::Update(void)
int GUISlider::NotifyTouch(TOUCH_STATE state, int x, int y)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return -1;
static bool dragging = false;
diff --git a/gui/slidervalue.cpp b/gui/slidervalue.cpp
index 088620a21..b53797b25 100644
--- a/gui/slidervalue.cpp
+++ b/gui/slidervalue.cpp
@@ -62,7 +62,7 @@ GUISliderValue::GUISliderValue(xml_node<>* node) : GUIObject(node)
}
mLabel = new GUIText(node);
- if(mLabel->Render() < 0)
+ if (mLabel->Render() < 0)
{
delete mLabel;
mLabel = NULL;
@@ -156,7 +156,7 @@ GUISliderValue::GUISliderValue(xml_node<>* node) : GUIObject(node)
mFontHeight = mFont->GetHeight();
- if(mShowCurr)
+ if (mShowCurr)
{
int maxLen = std::max(strlen(mMinStr.c_str()), strlen(mMaxStr.c_str()));
mValueStr = new char[maxLen+1];
@@ -182,10 +182,10 @@ GUISliderValue::~GUISliderValue()
void GUISliderValue::loadValue(bool force)
{
- if(!mVariable.empty())
+ if (!mVariable.empty())
{
int value = DataManager::GetIntValue(mVariable);
- if(mValue == value && !force)
+ if (mValue == value && !force)
return;
mValue = value;
@@ -208,7 +208,7 @@ int GUISliderValue::SetRenderPos(int x, int y, int w, int h)
}
mRenderH = mSliderH;
- if(mShowCurr)
+ if (mShowCurr)
mRenderH += mFontHeight;
if (mLabel)
@@ -230,7 +230,7 @@ int GUISliderValue::SetRenderPos(int x, int y, int w, int h)
mActionW = mRenderW;
mActionH = mRenderH;
- if(mBackgroundImage && mBackgroundImage->GetResource())
+ if (mBackgroundImage && mBackgroundImage->GetResource())
{
mLineW = mBackgroundImage->GetWidth();
mLineH = mBackgroundImage->GetHeight();
@@ -260,7 +260,7 @@ int GUISliderValue::Render(void)
return 0;
}
- if(mLabel)
+ if (mLabel)
{
int w, h;
mLabel->GetCurrentBounds(w, h);
@@ -270,12 +270,12 @@ int GUISliderValue::Render(void)
mLabel->SetRenderPos(textX, mRenderY);
}
int res = mLabel->Render();
- if(res < 0)
+ if (res < 0)
return res;
}
// line
- if(mBackgroundImage && mBackgroundImage->GetResource())
+ if (mBackgroundImage && mBackgroundImage->GetResource())
{
gr_blit(mBackgroundImage->GetResource(), 0, 0, mLineW, mLineH, mLineX, mLineY);
}
@@ -288,10 +288,10 @@ int GUISliderValue::Render(void)
// slider
uint32_t sliderX = mLineX + (mValuePct*(mLineW - mSliderW))/100;
- if(mHandleImage && mHandleImage->GetResource())
+ if (mHandleImage && mHandleImage->GetResource())
{
gr_surface s = mHandleImage->GetResource();
- if(mDragging && mHandleHoverImage && mHandleHoverImage->GetResource())
+ if (mDragging && mHandleHoverImage && mHandleHoverImage->GetResource())
s = mHandleHoverImage->GetResource();
gr_blit(s, 0, 0, mSliderW, mSliderH, sliderX, mLineY + (mLineH/2 - mSliderH/2));
}
@@ -302,16 +302,16 @@ int GUISliderValue::Render(void)
}
void *fontResource = NULL;
- if(mFont) fontResource = mFont->GetResource();
+ if (mFont) fontResource = mFont->GetResource();
gr_color(mTextColor.red, mTextColor.green, mTextColor.blue, mTextColor.alpha);
- if(mShowRange)
+ if (mShowRange)
{
int rangeY = (mLineY - mLineH/2) - mFontHeight/2;
gr_textEx_scaleW(mRenderX + mPadding/2, rangeY, mMinStr.c_str(), fontResource, mRenderW, TOP_LEFT, 0);
gr_textEx_scaleW(mLineX + mLineW + mPadding/2, rangeY, mMaxStr.c_str(), fontResource, mRenderW, TOP_LEFT, 0);
}
- if(mValueStr && mShowCurr)
+ if (mValueStr && mShowCurr)
{
sprintf(mValueStr, "%d", mValue);
int textW = measureText(mValueStr);
@@ -329,7 +329,7 @@ int GUISliderValue::Update(void)
if (!mRendered)
return 2;
- if(mLabel)
+ if (mLabel)
return mLabel->Update();
return 0;
}
@@ -406,7 +406,7 @@ int GUISliderValue::NotifyVarChange(const std::string& varName, const std::strin
mLabel->NotifyVarChange(varName, value);
if (varName == mVariable) {
int newVal = atoi(value.c_str());
- if(newVal != mValue) {
+ if (newVal != mValue) {
mValue = newVal;
mValuePct = pctFromValue(mValue);
mRendered = false;
diff --git a/gui/terminal.cpp b/gui/terminal.cpp
index b4194d0fb..fe80fb097 100644
--- a/gui/terminal.cpp
+++ b/gui/terminal.cpp
@@ -500,7 +500,7 @@ private:
uint32_t u8state = 0, u8cp = 0;
std::string& s = lines[y].text;
unpackedLine.cells.clear();
- for(size_t i = 0; i < s.size(); ++i) {
+ for (size_t i = 0; i < s.size(); ++i) {
uint32_t rc = utf8decode(&u8state, &u8cp, (unsigned char)s[i]);
if (rc == UTF8_ACCEPT)
unpackedLine.cells.push_back(Cell(u8cp));
@@ -776,7 +776,10 @@ GUITerminal::GUITerminal(xml_node<>* node) : GUIScrollList(node)
lastCondition = false;
if (!node) {
- mRenderX = 0; mRenderY = 0; mRenderW = gr_fb_width(); mRenderH = gr_fb_height();
+ mRenderX = 0;
+ mRenderY = 0;
+ mRenderW = gr_fb_width();
+ mRenderH = gr_fb_height();
}
engine = &gEngine;
@@ -785,7 +788,7 @@ GUITerminal::GUITerminal(xml_node<>* node) : GUIScrollList(node)
int GUITerminal::Update(void)
{
- if(!isConditionTrue()) {
+ if (!isConditionTrue()) {
lastCondition = false;
return 0;
}
@@ -816,7 +819,7 @@ int GUITerminal::Update(void)
// Return 0 on success, >0 to ignore remainder of touch, and <0 on error
int GUITerminal::NotifyTouch(TOUCH_STATE state, int x, int y)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return -1;
// TODO: grab focus correctly
diff --git a/gui/textbox.cpp b/gui/textbox.cpp
index 2e2512c50..2c7d09f99 100644
--- a/gui/textbox.cpp
+++ b/gui/textbox.cpp
@@ -98,7 +98,7 @@ int GUITextBox::NotifyVarChange(const std::string& varName, const std::string& v
{
GUIScrollList::NotifyVarChange(varName, value);
- if(!isConditionTrue() || mIsStatic)
+ if (!isConditionTrue() || mIsStatic)
return 0;
// Check to see if the variable exists in mText
diff --git a/gui/theme/common/portrait.xml b/gui/theme/common/portrait.xml
index b36b5a615..80e358b77 100644
--- a/gui/theme/common/portrait.xml
+++ b/gui/theme/common/portrait.xml
@@ -386,9 +386,9 @@
</checkbox>
<checkbox>
- <placement x="%indent%" y="%row13a_y%" />
+ <placement x="%indent%" y="%row13a_y%"/>
<text>{@install_reboot_chk=Reboot after installation is complete}</text>
- <data variable="tw_install_reboot" />
+ <data variable="tw_install_reboot"/>
</checkbox>
<checkbox>
diff --git a/gui/twmsg.cpp b/gui/twmsg.cpp
index 57f192234..ebd6fc313 100644
--- a/gui/twmsg.cpp
+++ b/gui/twmsg.cpp
@@ -33,7 +33,7 @@ class LocalLookup : public StringLookup
{
const std::vector<std::string>& vars;
const StringLookup& next;
- public:
+public:
LocalLookup(const std::vector<std::string>& vars, const StringLookup& next) : vars(vars), next(next) {}
virtual std::string operator()(const std::string& name) const
{
diff --git a/openrecoveryscript.cpp b/openrecoveryscript.cpp
index f9c610a7c..d94775acc 100644
--- a/openrecoveryscript.cpp
+++ b/openrecoveryscript.cpp
@@ -98,8 +98,8 @@ int OpenRecoveryScript::run_script_file(void) {
FILE *fp = fopen(SCRIPT_FILE_TMP, "r");
int ret_val = 0, cindex, line_len, i, remove_nl, install_cmd = 0, sideload = 0;
char script_line[SCRIPT_COMMAND_SIZE], command[SCRIPT_COMMAND_SIZE],
- value[SCRIPT_COMMAND_SIZE], mount[SCRIPT_COMMAND_SIZE],
- value1[SCRIPT_COMMAND_SIZE], value2[SCRIPT_COMMAND_SIZE];
+ value[SCRIPT_COMMAND_SIZE], mount[SCRIPT_COMMAND_SIZE],
+ value1[SCRIPT_COMMAND_SIZE], value2[SCRIPT_COMMAND_SIZE];
char *val_start, *tok;
if (fp != NULL) {
@@ -120,9 +120,9 @@ int OpenRecoveryScript::run_script_file(void) {
memset(command, 0, sizeof(command));
memset(value, 0, sizeof(value));
if ((int)script_line[line_len - 1] == 10)
- remove_nl = 2;
- else
- remove_nl = 1;
+ remove_nl = 2;
+ else
+ remove_nl = 1;
if (cindex != 0) {
strncpy(command, script_line, cindex);
LOGINFO("command is: '%s'\n", command);
diff --git a/partition.cpp b/partition.cpp
index ae27fd0cc..9ff906154 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -2322,7 +2322,7 @@ bool TWPartition::Raw_Read_Write(PartitionSettings *part_settings) {
while (Remain > 0) {
if (Remain < RW_Block_Size)
bs = (ssize_t)(Remain);
- if (read(src_fd, buffer, bs) != bs) {
+ if (read(src_fd, buffer, bs) != bs) {
LOGINFO("Error reading source fd (%s)\n", strerror(errno));
goto exit;
}
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 40e08634a..ffa43eeff 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -569,7 +569,6 @@ bool TWPartitionManager::Make_MD5(PartitionSettings *part_settings)
return true;
}
-
bool TWPartitionManager::Backup_Partition(PartitionSettings *part_settings) {
time_t start, stop;
int use_compression, adb_control_bu_fd;
@@ -730,7 +729,6 @@ int TWPartitionManager::Run_Backup(bool adbbackup) {
if (!Mount_Current_Storage(true))
return false;
-
DataManager::GetValue(TW_SKIP_MD5_GENERATE_VAR, do_md5);
if (do_md5 == 0)
part_settings.generate_md5 = true;
@@ -842,7 +840,6 @@ int TWPartitionManager::Run_Backup(bool adbbackup) {
part_settings.Part = Find_Partition_By_Path(backup_path);
if (part_settings.Part != NULL) {
if (!Backup_Partition(&part_settings))
-
return false;
} else {
gui_msg(Msg(msg::kError, "unable_to_locate_partition=Unable to locate '{1}' partition for backup calculations.")(backup_path));
@@ -920,7 +917,6 @@ bool TWPartitionManager::Restore_Partition(PartitionSettings *part_settings) {
time(&Start);
-
if (!part_settings->Part->Restore(part_settings)) {
TWFunc::SetPerformanceMode(false);
return false;
@@ -2078,13 +2074,13 @@ TWPartition *TWPartitionManager::Get_Default_Storage_Partition()
{
TWPartition *res = NULL;
for (std::vector<TWPartition*>::iterator iter = Partitions.begin(); iter != Partitions.end(); ++iter) {
- if(!(*iter)->Is_Storage)
+ if (!(*iter)->Is_Storage)
continue;
- if((*iter)->Is_Settings_Storage)
+ if ((*iter)->Is_Settings_Storage)
return *iter;
- if(!res)
+ if (!res)
res = *iter;
}
return res;
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 92d3a3b9d..9296c346d 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -64,7 +64,7 @@ int TWFunc::Exec_Cmd(const string& cmd, string &result) {
int ret = 0;
exec = __popen(cmd.c_str(), "r");
if (!exec) return -1;
- while(!feof(exec)) {
+ while (!feof(exec)) {
if (fgets(buffer, 128, exec) != NULL) {
result += buffer;
}
@@ -184,15 +184,15 @@ int TWFunc::Try_Decrypting_File(string fn, string password) {
size_t _key_data_len = 0;
// mostly kanged from OpenAES oaes.c
- for( _j = 0; _j < 32; _j++ )
+ for ( _j = 0; _j < 32; _j++ )
_key_data[_j] = _j + 1;
_key_data_len = password.size();
- if( 16 >= _key_data_len )
+ if ( 16 >= _key_data_len )
_key_data_len = 16;
- else if( 24 >= _key_data_len )
+ else if ( 24 >= _key_data_len )
_key_data_len = 24;
else
- _key_data_len = 32;
+ _key_data_len = 32;
memcpy(_key_data, password.c_str(), password.size());
ctx = oaes_alloc();
@@ -282,13 +282,13 @@ std::string TWFunc::Remove_Trailing_Slashes(const std::string& path, bool leaveL
std::string res;
size_t last_idx = 0, idx = 0;
- while(last_idx != std::string::npos)
+ while (last_idx != std::string::npos)
{
- if(last_idx != 0)
+ if (last_idx != 0)
res += '/';
idx = path.find_first_of('/', last_idx);
- if(idx == std::string::npos) {
+ if (idx == std::string::npos) {
res += path.substr(last_idx, idx);
break;
}
@@ -297,7 +297,7 @@ std::string TWFunc::Remove_Trailing_Slashes(const std::string& path, bool leaveL
last_idx = path.find_first_not_of('/', idx);
}
- if(leaveLast)
+ if (leaveLast)
res += '/';
return res;
}
@@ -318,13 +318,13 @@ vector<string> TWFunc::split_string(const string &in, char del, bool skip_empty)
string field;
istringstream f(in);
if (del == '\n') {
- while(getline(f, field)) {
+ while (getline(f, field)) {
if (field.empty() && skip_empty)
continue;
- res.push_back(field);
+ res.push_back(field);
}
} else {
- while(getline(f, field, del)) {
+ while (getline(f, field, del)) {
if (field.empty() && skip_empty)
continue;
res.push_back(field);
@@ -894,44 +894,44 @@ void TWFunc::Fixup_Time_On_Boot()
struct dirent *dt;
std::string ats_path;
- if(!PartitionManager.Mount_By_Path("/data", false))
+ if (!PartitionManager.Mount_By_Path("/data", false))
return;
// Prefer ats_2, it seems to be the one we want according to logcat on hammerhead
// - it is the one for ATS_TOD (time of day?).
// However, I never saw a device where the offset differs between ats files.
- for(size_t i = 0; i < (sizeof(paths)/sizeof(paths[0])); ++i)
+ for (size_t i = 0; i < (sizeof(paths)/sizeof(paths[0])); ++i)
{
DIR *d = opendir(paths[i]);
- if(!d)
+ if (!d)
continue;
- while((dt = readdir(d)))
+ while ((dt = readdir(d)))
{
- if(dt->d_type != DT_REG || strncmp(dt->d_name, "ats_", 4) != 0)
+ if (dt->d_type != DT_REG || strncmp(dt->d_name, "ats_", 4) != 0)
continue;
- if(ats_path.empty() || strcmp(dt->d_name, "ats_2") == 0)
+ if (ats_path.empty() || strcmp(dt->d_name, "ats_2") == 0)
ats_path = std::string(paths[i]).append(dt->d_name);
}
closedir(d);
}
- if(ats_path.empty())
+ if (ats_path.empty())
{
LOGINFO("TWFunc::Fixup_Time: no ats files found, leaving untouched!\n");
return;
}
f = fopen(ats_path.c_str(), "r");
- if(!f)
+ if (!f)
{
LOGINFO("TWFunc::Fixup_Time: failed to open file %s\n", ats_path.c_str());
return;
}
- if(fread(&offset, sizeof(offset), 1, f) != 1)
+ if (fread(&offset, sizeof(offset), 1, f) != 1)
{
LOGINFO("TWFunc::Fixup_Time: failed load uint64 from file %s\n", ats_path.c_str());
fclose(f);
@@ -946,7 +946,7 @@ void TWFunc::Fixup_Time_On_Boot()
tv.tv_sec += offset/1000;
tv.tv_usec += (offset%1000)*1000;
- while(tv.tv_usec >= 1000000)
+ while (tv.tv_usec >= 1000000)
{
++tv.tv_sec;
tv.tv_usec -= 1000000;
@@ -964,13 +964,13 @@ std::vector<std::string> TWFunc::Split_String(const std::string& str, const std:
std::vector<std::string> res;
size_t idx = 0, idx_last = 0;
- while(idx < str.size())
+ while (idx < str.size())
{
idx = str.find_first_of(delimiter, idx_last);
- if(idx == std::string::npos)
+ if (idx == std::string::npos)
idx = str.size();
- if(idx-idx_last != 0 || !removeEmpty)
+ if (idx-idx_last != 0 || !removeEmpty)
res.push_back(str.substr(idx_last, idx-idx_last));
idx_last = idx + delimiter.size();
@@ -984,12 +984,12 @@ bool TWFunc::Create_Dir_Recursive(const std::string& path, mode_t mode, uid_t ui
std::vector<std::string> parts = Split_String(path, "/");
std::string cur_path;
struct stat info;
- for(size_t i = 0; i < parts.size(); ++i)
+ for (size_t i = 0; i < parts.size(); ++i)
{
cur_path += "/" + parts[i];
- if(stat(cur_path.c_str(), &info) < 0 || !S_ISDIR(info.st_mode))
+ if (stat(cur_path.c_str(), &info) < 0 || !S_ISDIR(info.st_mode))
{
- if(mkdir(cur_path.c_str(), mode) < 0)
+ if (mkdir(cur_path.c_str(), mode) < 0)
return false;
chown(cur_path.c_str(), uid, gid);
}
diff --git a/twrp.cpp b/twrp.cpp
index 353127943..b247458ce 100644
--- a/twrp.cpp
+++ b/twrp.cpp
@@ -254,7 +254,7 @@ int main(int argc, char **argv) {
printf("\n");
}
- if(crash_counter == 0) {
+ if (crash_counter == 0) {
property_list(Print_Prop, NULL);
printf("\n");
} else {
@@ -309,7 +309,7 @@ int main(int argc, char **argv) {
GUIConsole::Translate_Now();
// Fixup the RTC clock on devices which require it
- if(crash_counter == 0)
+ if (crash_counter == 0)
TWFunc::Fixup_Time_On_Boot();
// Run any outstanding OpenRecoveryScript
diff --git a/twrpTar.cpp b/twrpTar.cpp
index 27c7c7b1b..4a71159cc 100644
--- a/twrpTar.cpp
+++ b/twrpTar.cpp
@@ -987,7 +987,7 @@ int twrpTar::createTar() {
fd = pipes[1];
init_libtar_no_buffer(progress_pipe_fd);
tar_type.writefunc = write_tar_no_buffer;
- if(tar_fdopen(&t, fd, charRootDir, &tar_type, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
+ if (tar_fdopen(&t, fd, charRootDir, &tar_type, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
close(fd);
LOGINFO("tar_fdopen failed\n");
gui_err("backup_error=Error creating backup.");
@@ -1047,7 +1047,7 @@ int twrpTar::createTar() {
fd = pigzfd[1]; // copy parent output
init_libtar_no_buffer(progress_pipe_fd);
tar_type.writefunc = write_tar_no_buffer;
- if(tar_fdopen(&t, fd, charRootDir, &tar_type, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
+ if (tar_fdopen(&t, fd, charRootDir, &tar_type, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
close(fd);
LOGINFO("tar_fdopen failed\n");
gui_err("backup_error=Error creating backup.");
@@ -1097,7 +1097,7 @@ int twrpTar::createTar() {
fd = oaesfd[1]; // copy parent output
init_libtar_no_buffer(progress_pipe_fd);
tar_type.writefunc = write_tar_no_buffer;
- if(tar_fdopen(&t, fd, charRootDir, &tar_type, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
+ if (tar_fdopen(&t, fd, charRootDir, &tar_type, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
close(fd);
LOGINFO("tar_fdopen failed\n");
gui_err("backup_error=Error creating backup.");
@@ -1220,7 +1220,7 @@ int twrpTar::openTar() {
close(pipes[1]);
close(pipes[3]);
fd = pipes[2];
- if(tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
+ if (tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
close(fd);
LOGINFO("tar_fdopen failed\n");
gui_err("restore_error=Error during restore process.");
@@ -1270,7 +1270,7 @@ int twrpTar::openTar() {
// Parent
close(oaesfd[1]); // close parent output
fd = oaesfd[0]; // copy parent input
- if(tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
+ if (tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
close(fd);
LOGINFO("tar_fdopen failed\n");
gui_err("restore_error=Error during restore process.");
@@ -1536,7 +1536,7 @@ unsigned long long twrpTar::uncompressedSize(string filename) {
*/
split = TWFunc::split_string(result, ' ', true);
if (split.size() > 4)
- total_size = atoi(split[5].c_str());
+ total_size = atoi(split[5].c_str());
}
} else if (current_archive_type == COMPRESSED_ENCRYPTED) {
// File is encrypted and may be compressed
@@ -1562,7 +1562,7 @@ unsigned long long twrpTar::uncompressedSize(string filename) {
*/
split = TWFunc::split_string(result, ' ', true);
if (split.size() > 4)
- total_size = atoi(split[5].c_str());
+ total_size = atoi(split[5].c_str());
}
} else {
total_size = TWFunc::Get_File_Size(filename);
diff --git a/twrpTar.h b/twrpTar.h
index 425a831f2..2348487e3 100644
--- a/twrpTar.h
+++ b/twrpTar.h
@@ -23,4 +23,3 @@ ssize_t write_tar(int fd, const void *buffer, size_t size);
ssize_t write_tar_no_buffer(int fd, const void *buffer, size_t size);
#endif // _TWRPTAR_HEADER
-
diff --git a/twrpTar.hpp b/twrpTar.hpp
index 78c4c5978..92674ee61 100644
--- a/twrpTar.hpp
+++ b/twrpTar.hpp
@@ -44,7 +44,6 @@ struct thread_data_struct {
unsigned thread_id;
};
-
class twrpTar {
public:
twrpTar();