[Spice-commits] 4 commits - vdagent/vdagent.cpp vdservice/vdservice.cpp
Frediano Ziglio
fziglio at kemper.freedesktop.org
Thu Sep 1 14:48:04 UTC 2016
vdagent/vdagent.cpp | 28 ++++++++++++++--------------
vdservice/vdservice.cpp | 2 +-
2 files changed, 15 insertions(+), 15 deletions(-)
New commits:
commit 25ef63420209e0c995d56e62c6215a62df0167a6
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Aug 16 06:48:48 2016 +0100
Make some members constant
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index aa1a3cc..d4f0d45 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -106,9 +106,9 @@ private:
static VOID CALLBACK read_completion(DWORD err, DWORD bytes, LPOVERLAPPED overlapped);
static VOID CALLBACK write_completion(DWORD err, DWORD bytes, LPOVERLAPPED overlapped);
void dispatch_message(VDAgentMessage* msg, uint32_t port);
- uint32_t get_clipboard_format(uint32_t type);
- uint32_t get_clipboard_type(uint32_t format);
- DWORD get_cximage_format(uint32_t type);
+ uint32_t get_clipboard_format(uint32_t type) const;
+ uint32_t get_clipboard_type(uint32_t format) const;
+ DWORD get_cximage_format(uint32_t type) const;
enum { owner_none, owner_guest, owner_client };
void set_clipboard_owner(int new_owner);
enum { CONTROL_STOP, CONTROL_DESKTOP_SWITCH, CONTROL_LOGON, CONTROL_CLIPBOARD };
@@ -1218,7 +1218,7 @@ void VDAgent::handle_clipboard_release()
set_clipboard_owner(owner_none);
}
-uint32_t VDAgent::get_clipboard_format(uint32_t type)
+uint32_t VDAgent::get_clipboard_format(uint32_t type) const
{
for (unsigned int i = 0; i < clipboard_formats_count; i++) {
for (const uint32_t* ptype = clipboard_formats[i].types; *ptype; ptype++) {
@@ -1230,7 +1230,7 @@ uint32_t VDAgent::get_clipboard_format(uint32_t type)
return 0;
}
-uint32_t VDAgent::get_clipboard_type(uint32_t format)
+uint32_t VDAgent::get_clipboard_type(uint32_t format) const
{
const uint32_t* types = NULL;
@@ -1250,7 +1250,7 @@ uint32_t VDAgent::get_clipboard_type(uint32_t format)
return 0;
}
-DWORD VDAgent::get_cximage_format(uint32_t type)
+DWORD VDAgent::get_cximage_format(uint32_t type) const
{
for (unsigned int i = 0; i < SPICE_N_ELEMENTS(image_types); i++) {
if (image_types[i].type == type) {
commit 2cb102280a93a3997be385dbea7eda5e3d375d1e
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Aug 16 06:48:28 2016 +0100
Make static and constant some lookup arrays
Make clipboard_formats and image_types static and constant.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index ded6221..aa1a3cc 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -46,7 +46,7 @@ typedef struct VDClipboardFormat {
uint32_t types[VD_CLIPBOARD_FORMAT_MAX_TYPES];
} VDClipboardFormat;
-VDClipboardFormat clipboard_formats[] = {
+static const VDClipboardFormat clipboard_formats[] = {
{CF_UNICODETEXT, {VD_AGENT_CLIPBOARD_UTF8_TEXT, 0}},
//FIXME: support more image types
{CF_DIB, {VD_AGENT_CLIPBOARD_IMAGE_PNG, VD_AGENT_CLIPBOARD_IMAGE_BMP, 0}},
@@ -59,7 +59,7 @@ typedef struct ImageType {
DWORD cximage_format;
} ImageType;
-static ImageType image_types[] = {
+static const ImageType image_types[] = {
{VD_AGENT_CLIPBOARD_IMAGE_PNG, CXIMAGE_FORMAT_PNG},
{VD_AGENT_CLIPBOARD_IMAGE_BMP, CXIMAGE_FORMAT_BMP},
};
@@ -997,7 +997,7 @@ void VDAgent::on_clipboard_grab()
}
for (unsigned int i = 0; i < clipboard_formats_count; i++) {
if (IsClipboardFormatAvailable(clipboard_formats[i].format)) {
- for (uint32_t* ptype = clipboard_formats[i].types; *ptype; ptype++) {
+ for (const uint32_t* ptype = clipboard_formats[i].types; *ptype; ptype++) {
types[count++] = *ptype;
}
}
@@ -1221,7 +1221,7 @@ void VDAgent::handle_clipboard_release()
uint32_t VDAgent::get_clipboard_format(uint32_t type)
{
for (unsigned int i = 0; i < clipboard_formats_count; i++) {
- for (uint32_t* ptype = clipboard_formats[i].types; *ptype; ptype++) {
+ for (const uint32_t* ptype = clipboard_formats[i].types; *ptype; ptype++) {
if (*ptype == type) {
return clipboard_formats[i].format;
}
@@ -1232,7 +1232,7 @@ uint32_t VDAgent::get_clipboard_format(uint32_t type)
uint32_t VDAgent::get_clipboard_type(uint32_t format)
{
- uint32_t* types = NULL;
+ const uint32_t* types = NULL;
for (unsigned int i = 0; i < clipboard_formats_count && !types; i++) {
if (clipboard_formats[i].format == format) {
@@ -1242,7 +1242,7 @@ uint32_t VDAgent::get_clipboard_type(uint32_t format)
if (!types) {
return 0;
}
- for (uint32_t* ptype = types; *ptype; ptype++) {
+ for (const uint32_t* ptype = types; *ptype; ptype++) {
if (_grab_types.find(*ptype) != _grab_types.end()) {
return *ptype;
}
commit 7555e215458dbfb60067ba668a37c922a0fe4bdb
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Aug 16 06:46:53 2016 +0100
Reuse SPICE_N_ELEMENTS macro
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index cde29e6..ded6221 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -52,7 +52,7 @@ VDClipboardFormat clipboard_formats[] = {
{CF_DIB, {VD_AGENT_CLIPBOARD_IMAGE_PNG, VD_AGENT_CLIPBOARD_IMAGE_BMP, 0}},
};
-#define clipboard_formats_count (sizeof(clipboard_formats) / sizeof(clipboard_formats[0]))
+#define clipboard_formats_count SPICE_N_ELEMENTS(clipboard_formats)
typedef struct ImageType {
uint32_t type;
@@ -1252,7 +1252,7 @@ uint32_t VDAgent::get_clipboard_type(uint32_t format)
DWORD VDAgent::get_cximage_format(uint32_t type)
{
- for (unsigned int i = 0; i < sizeof(image_types) / sizeof(image_types[0]); i++) {
+ for (unsigned int i = 0; i < SPICE_N_ELEMENTS(image_types); i++) {
if (image_types[i].type == type) {
return image_types[i].cximage_format;
}
commit 89445cd1b4b0ee6149112932dcfc2fc73b7f30fe
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Fri Aug 12 13:57:21 2016 +0100
Make session_events static and const
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp
index d2bedaa..2d7b5b9 100644
--- a/vdservice/vdservice.cpp
+++ b/vdservice/vdservice.cpp
@@ -233,7 +233,7 @@ bool VDService::uninstall()
return ret;
}
-const char* session_events[] = {
+static const char* const session_events[] = {
"INVALID", "CONNECT", "DISCONNECT", "REMOTE_CONNECT", "REMOTE_DISCONNECT", "LOGON", "LOGOFF",
"LOCK", "UNLOCK", "REMOTE_CONTROL"
};
More information about the Spice-commits
mailing list