Skip to content

Commit 609f190

Browse files
committed
Fix code style by running clang-format over the whole thing
Specifically: $ git filter-branch --tree-filter 'clang-format --style=file -i *.cpp *.c *.h' the-previous-commit..HEAD
1 parent 5b0befe commit 609f190

25 files changed

+1819
-1849
lines changed

Ck.cpp

+53-63
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* SLiM - Simple Login Manager
1+
/*
2+
* SLiM - Simple Login Manager
23
* Copyright (C) 2011 David Hauweele
34
*
45
* This program is free software; you can redistribute it and/or modify
@@ -10,50 +11,44 @@
1011
#include <cstdio>
1112
#include <iostream>
1213

13-
#include <ck-connector.h>
14-
#include <X11/Xlib.h>
1514
#include <X11/Xatom.h>
15+
#include <X11/Xlib.h>
16+
#include <ck-connector.h>
1617
#include <stdarg.h>
1718

1819
#include "Ck.h"
1920

20-
namespace Ck {
21-
Exception::Exception(const std::string &func,
22-
const std::string &errstr):
23-
func(func),
24-
errstr(errstr)
25-
{}
26-
27-
dbus_bool_t
28-
Session::ck_connector_open_graphic_session(
29-
const std::string &display,
30-
uid_t uid)
21+
namespace Ck
22+
{
23+
Exception::Exception(const std::string & func, const std::string & errstr)
24+
: func(func), errstr(errstr)
25+
{
26+
}
27+
28+
dbus_bool_t Session::ck_connector_open_graphic_session(
29+
const std::string & display, uid_t uid)
3130
{
3231
dbus_bool_t local = true;
33-
const char *session_type = "x11";
34-
const char *x11_display = display.c_str();
35-
const char *x11_device = get_x11_device(display);
36-
const char *remote_host = "";
37-
const char *display_dev = "";
32+
const char * session_type = "x11";
33+
const char * x11_display = display.c_str();
34+
const char * x11_device = get_x11_device(display);
35+
const char * remote_host = "";
36+
const char * display_dev = "";
3837

3938
return ck_connector_open_session_with_parameters(ckc, &error,
40-
"unix-user", &uid,
41-
"session-type", &session_type,
42-
"x11-display", &x11_display,
43-
"x11-display-device", &x11_device,
44-
"display-device", &display_dev,
45-
"remote-host-name", &remote_host,
46-
"is-local", &local,
39+
"unix-user", &uid, "session-type", &session_type, "x11-display",
40+
&x11_display, "x11-display-device", &x11_device, "display-device",
41+
&display_dev, "remote-host-name", &remote_host, "is-local", &local,
4742
NULL);
4843
}
4944

50-
const char * Session::get_x11_device(const std::string &display)
45+
const char * Session::get_x11_device(const std::string & display)
5146
{
5247
static char device[32];
5348

54-
Display *xdisplay = XOpenDisplay(display.c_str());
49+
Display * xdisplay = XOpenDisplay(display.c_str());
5550

56-
if(!xdisplay)
51+
if (!xdisplay)
5752
throw Exception(__func__, "cannot open display");
5853

5954
Window root;
@@ -62,59 +57,59 @@ namespace Ck {
6257
int return_format;
6358
unsigned long return_count;
6459
unsigned long bytes_left;
65-
unsigned char *return_value;
60+
unsigned char * return_value;
6661
long vt;
6762

6863
xfree86_vt_atom = XInternAtom(xdisplay, "XFree86_VT", true);
6964

70-
if(xfree86_vt_atom == None)
65+
if (xfree86_vt_atom == None)
7166
throw Exception(__func__, "cannot get XFree86_VT");
7267

7368
root = DefaultRootWindow(xdisplay);
7469

75-
if(XGetWindowProperty(xdisplay, root, xfree86_vt_atom,
76-
0L, 1L, false, XA_INTEGER,
77-
&return_type_atom, &return_format,
78-
&return_count, &bytes_left,
79-
&return_value) != Success)
70+
if (XGetWindowProperty(xdisplay, root, xfree86_vt_atom, 0L, 1L, false,
71+
XA_INTEGER, &return_type_atom, &return_format, &return_count,
72+
&bytes_left, &return_value) != Success)
8073
throw Exception(__func__, "cannot get root window property");
8174

82-
if(return_type_atom != XA_INTEGER)
75+
if (return_type_atom != XA_INTEGER)
8376
throw Exception(__func__, "bad atom type");
8477

85-
if(return_format != 32)
78+
if (return_format != 32)
8679
throw Exception(__func__, "invalid return format");
8780

88-
if(return_count != 1)
81+
if (return_count != 1)
8982
throw Exception(__func__, "invalid count");
9083

91-
if(bytes_left != 0)
84+
if (bytes_left != 0)
9285
throw Exception(__func__, "invalid bytes left");
9386

9487
vt = *((long *)return_value);
9588

9689
std::snprintf(device, 32, "/dev/tty%ld", vt);
9790

98-
if(return_value)
91+
if (return_value)
9992
XFree(return_value);
10093

10194
return device;
10295
}
10396

104-
void Session::open_session(const std::string &display, uid_t uid)
97+
void Session::open_session(const std::string & display, uid_t uid)
10598
{
10699
ckc = ck_connector_new();
107100

108-
if(!ckc)
109-
throw Exception(__func__, "error setting up connection to ConsoleKit");
101+
if (!ckc)
102+
throw Exception(
103+
__func__, "error setting up connection to ConsoleKit");
110104

111105
if (!ck_connector_open_graphic_session(display, uid)) {
112-
if(dbus_error_is_set(&error))
106+
if (dbus_error_is_set(&error))
113107
throw Exception(__func__, error.message);
114108
else
115-
throw Exception(__func__, "cannot open ConsoleKit session: OOM,"
116-
" DBus system bus not available or insufficient"
117-
" privileges");
109+
throw Exception(__func__,
110+
"cannot open ConsoleKit session: OOM,"
111+
" DBus system bus not available or insufficient"
112+
" privileges");
118113
}
119114
}
120115

@@ -125,28 +120,23 @@ namespace Ck {
125120

126121
void Session::close_session()
127122
{
128-
if(!ck_connector_close_session(ckc, &error)) {
129-
if(dbus_error_is_set(&error))
123+
if (!ck_connector_close_session(ckc, &error)) {
124+
if (dbus_error_is_set(&error))
130125
throw Exception(__func__, error.message);
131126
else
132-
throw Exception(__func__, "cannot close ConsoleKit session: OOM,"
133-
" DBus system bus not available or insufficient"
134-
" privileges");
127+
throw Exception(__func__,
128+
"cannot close ConsoleKit session: OOM,"
129+
" DBus system bus not available or insufficient"
130+
" privileges");
135131
}
136132
}
137133

138-
Session::Session()
139-
{
140-
dbus_error_init(&error);
141-
}
134+
Session::Session() { dbus_error_init(&error); }
142135

143-
Session::~Session()
144-
{
145-
dbus_error_free(&error);
146-
}
147-
}
136+
Session::~Session() { dbus_error_free(&error); }
137+
} // namespace Ck
148138

149-
std::ostream& operator<<( std::ostream& os, const Ck::Exception& e)
139+
std::ostream & operator<<(std::ostream & os, const Ck::Exception & e)
150140
{
151141
os << e.func << ": " << e.errstr;
152142
return os;

Ck.h

+18-14
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,36 @@
1515
#include <ck-connector.h>
1616
#include <dbus/dbus.h>
1717

18-
namespace Ck {
19-
class Exception {
18+
namespace Ck
19+
{
20+
class Exception
21+
{
2022
public:
2123
std::string func;
2224
std::string errstr;
23-
Exception(const std::string &func, const std::string &errstr);
25+
Exception(const std::string & func, const std::string & errstr);
2426
};
2527

26-
class Session {
28+
class Session
29+
{
2730
private:
28-
CkConnector *ckc;
31+
CkConnector * ckc;
2932
DBusError error;
3033

31-
const char *get_x11_device(const std::string &display);
32-
dbus_bool_t ck_connector_open_graphic_session(const std::string &display,
33-
uid_t uid);
34+
const char * get_x11_device(const std::string & display);
35+
dbus_bool_t ck_connector_open_graphic_session(
36+
const std::string & display, uid_t uid);
37+
3438
public:
35-
const char *get_xdg_session_cookie();
36-
void open_session(const std::string &display, uid_t uid);
39+
const char * get_xdg_session_cookie();
40+
void open_session(const std::string & display, uid_t uid);
3741
void close_session();
3842

39-
Session();
40-
~Session();
43+
Session();
44+
~Session();
4145
};
42-
}
46+
} // namespace Ck
4347

44-
std::ostream &operator<<(std::ostream &os, const Ck::Exception &e);
48+
std::ostream & operator<<(std::ostream & os, const Ck::Exception & e);
4549

4650
#endif /* _CK_H_ */

0 commit comments

Comments
 (0)