Skip to content

Commit

Permalink
Whitespace cleanup
Browse files Browse the repository at this point in the history
Change-Id: I93c65973679894bb8587da4b38b410d38036b8bd
  • Loading branch information
mdmower authored and Dees-Troy committed Jan 18, 2017
1 parent 55f2bda commit a8a89d1
Show file tree
Hide file tree
Showing 33 changed files with 238 additions and 240 deletions.
66 changes: 33 additions & 33 deletions data.cpp
Expand Up @@ -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());
Expand Down Expand Up @@ -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", "/");
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
{
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions exclude.cpp
Expand Up @@ -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);
Expand Down
36 changes: 18 additions & 18 deletions gui/action.cpp
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions gui/animation.cpp
Expand Up @@ -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;
Expand All @@ -99,7 +99,7 @@ int GUIAnimation::Render(void)

int GUIAnimation::Update(void)
{
if(!isConditionTrue())
if (!isConditionTrue())
return 0;

if (!mAnimation) return -1;
Expand Down
11 changes: 7 additions & 4 deletions gui/console.cpp
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -276,7 +279,7 @@ int GUIConsole::RenderConsole(void)

int GUIConsole::Render(void)
{
if(!isConditionTrue())
if (!isConditionTrue())
return 0;

if (mSlideout && mSlideoutState == hidden)
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions gui/fileselector.cpp
Expand Up @@ -127,7 +127,7 @@ GUIFileSelector::~GUIFileSelector()

int GUIFileSelector::Update(void)
{
if(!isConditionTrue())
if (!isConditionTrue())
return 0;

GUIScrollList::Update();
Expand Down Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion gui/fill.cpp
Expand Up @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions gui/gui.cpp
Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions gui/input.cpp
Expand Up @@ -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) {
Expand All @@ -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;

Expand Down

0 comments on commit a8a89d1

Please sign in to comment.