diff ui/processhelp_win.cpp @ 606:91dd38a71783

Style: run astyle on processhelp
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 18 Jun 2014 11:05:10 +0200
parents cfef809b890d
children 81a44b93229e
line wrap: on
line diff
--- a/ui/processhelp_win.cpp	Wed Jun 18 10:44:39 2014 +0200
+++ b/ui/processhelp_win.cpp	Wed Jun 18 11:05:10 2014 +0200
@@ -16,21 +16,20 @@
 
 #include <QDebug>
 
-struct EnumWindowsStruct
-{
-  EnumWindowsStruct() : windowId( 0 ) {}
-  DWORD pid;
-  HWND windowId;
+struct EnumWindowsStruct {
+    EnumWindowsStruct() : windowId(0) {}
+    DWORD pid;
+    HWND windowId;
 };
 
 PSID copySid(PSID from)
 {
-    if ( !from ) {
+    if (!from) {
         return 0;
     }
 
-    int sidLength = GetLengthSid( from );
-    PSID to = (PSID) xmalloc( sidLength );
+    int sidLength = GetLengthSid(from);
+    PSID to = (PSID) xmalloc(sidLength);
     CopySid(sidLength, to, from);
     return to;
 }
@@ -41,18 +40,18 @@
     PSID sid;
 
     OpenProcessToken(hProcess, TOKEN_READ, &hToken);
-    if ( hToken ) {
+    if (hToken) {
         DWORD size;
         PTOKEN_USER userStruct;
 
         // check how much space is needed
-        GetTokenInformation( hToken, TokenUser, NULL, 0, &size );
-        if ( ERROR_INSUFFICIENT_BUFFER == GetLastError() ) {
-            userStruct = reinterpret_cast<PTOKEN_USER>( new BYTE[size] );
-            GetTokenInformation( hToken, TokenUser, userStruct, size, &size );
+        GetTokenInformation(hToken, TokenUser, NULL, 0, &size);
+        if (ERROR_INSUFFICIENT_BUFFER == GetLastError()) {
+            userStruct = reinterpret_cast<PTOKEN_USER>(new BYTE[size]);
+            GetTokenInformation(hToken, TokenUser, userStruct, size, &size);
 
-            sid = copySid( userStruct->User.Sid );
-            CloseHandle( hToken );
+            sid = copySid(userStruct->User.Sid);
+            CloseHandle(hToken);
             delete [] userStruct;
             return sid;
         }
@@ -104,19 +103,19 @@
     pids.clear();
 
     do {
-        if ( QString::fromWCharArray(pe32.szExeFile) == processName ) {
+        if (QString::fromWCharArray(pe32.szExeFile) == processName) {
             PSID user_sid = getProcessOwner(GetCurrentProcess());
-            if ( user_sid ) {
+            if (user_sid) {
                 // Also check that we are the owner of that process
                 HANDLE hProcess = getProcessHandle(pe32.th32ProcessID);
-                if ( !hProcess ) {
+                if (!hProcess) {
                     continue;
                 }
 
                 PSID sid = getProcessOwner(hProcess);
                 PSID userSid = getProcessOwner(GetCurrentProcess());
-                if ( !sid || (userSid && !EqualSid(userSid, sid))) {
-                    free (sid);
+                if (!sid || (userSid && !EqualSid(userSid, sid))) {
+                    free(sid);
                     continue;
                 }
             }
@@ -124,7 +123,7 @@
             qDebug() << "found PID: " << (int)pe32.th32ProcessID;
         }
     } while (Process32Next(h, &pe32));
-    CloseHandle( h );
+    CloseHandle(h);
     return pids;
 }
 
@@ -132,7 +131,7 @@
 {
     const QList<int> pids = getProcessesIdForName(processName);
     int myPid = getpid();
-    foreach (int pid, pids) {
+    foreach(int pid, pids) {
         if (myPid != pid) {
             qDebug() << "Found another process with id: " << pid;
             return true;
@@ -141,27 +140,28 @@
     return false;
 }
 
-void ProcessHelp::activateWindowForProcess(const QString &executableName) {
+void ProcessHelp::activateWindowForProcess(const QString &executableName)
+{
     const QList<int> pids = getProcessesIdForName(executableName);
     int myPid = getpid();
     int foundPid = 0;
-    foreach (int pid, pids) {
+    foreach(int pid, pids) {
         if (myPid != pid) {
             qDebug() << "activateWindowForProcess(): PID to activate:" << pid;
             foundPid = pid;
             break;
         }
     }
-    if ( foundPid == 0 ) {
+    if (foundPid == 0) {
         return;
     }
     EnumWindowsStruct winStruct;
     winStruct.pid = foundPid;
-    EnumWindows( EnumWindowsProc, (LPARAM)&winStruct );
-    if ( winStruct.windowId == 0 ) {
+    EnumWindows(EnumWindowsProc, (LPARAM)&winStruct);
+    if (winStruct.windowId == 0) {
         return;
     }
-    SetForegroundWindow( winStruct.windowId );
+    SetForegroundWindow(winStruct.windowId);
 }
 #endif // WIN32
 

http://wald.intevation.org/projects/trustbridge/