Added world getter, use g_ascii_strtod
This commit is contained in:
parent
3d41f951f6
commit
bbae55b926
|
@ -76,24 +76,26 @@ gm_mcp_session_handle_open(GmMcpSession *session, gchar *line) {
|
|||
GmMcpPackageClass *pklass;
|
||||
gchar const *min_version = gm_mcp_find_value(fields, "version");
|
||||
gchar const *max_version = gm_mcp_find_value(fields, "to");
|
||||
gchar *minc, *maxc;
|
||||
double min_v, max_v, version;
|
||||
//gchar *minc, *maxc;
|
||||
gdouble min_v, max_v, version;
|
||||
|
||||
if (!(min_version && max_version)) {
|
||||
gm_debug_msg(DEBUG_MCP, "GmMcpSession.HandleOpen: invalid opening, minVersion OR "
|
||||
"maxVersion not found!");
|
||||
gm_debug_msg(DEBUG_MCP, "GmMcpSession.HandleOpen: invalid opening, "
|
||||
"min version or max_version not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
minc = gm_fix_decimal_point(g_strdup(min_version), strlen(min_version));
|
||||
maxc = gm_fix_decimal_point(g_strdup(max_version), strlen(max_version));
|
||||
|
||||
min_v = g_ascii_strtod(minc, NULL);
|
||||
max_v = g_ascii_strtod(maxc, NULL);
|
||||
//minc = gm_fix_decimal_point(g_strdup(min_version), strlen(min_version));
|
||||
//maxc = gm_fix_decimal_point(g_strdup(max_version), strlen(max_version));
|
||||
|
||||
min_v = g_ascii_strtod(min_version, NULL);
|
||||
max_v = g_ascii_strtod(max_version, NULL);
|
||||
|
||||
g_free(minc);
|
||||
g_free(maxc);
|
||||
|
||||
//g_free(minc);
|
||||
//g_free(maxc);
|
||||
|
||||
gm_debug_msg(DEBUG_MCP, "MinMaxVersion: %fd %fd", min_v, max_v);
|
||||
|
||||
version = gm_mcp_get_version(MCP_MIN_VERSION, MCP_MAX_VERSION,
|
||||
min_v, max_v);
|
||||
|
||||
|
@ -108,8 +110,8 @@ gm_mcp_session_handle_open(GmMcpSession *session, gchar *line) {
|
|||
p = gm_mcp_session_create_package(session, pklass,
|
||||
pklass->max_version);
|
||||
} else {
|
||||
gm_debug_msg(DEBUG_MCP, "GmMcpSession.HandleOpen: mcp server version does not "
|
||||
"match client version!");
|
||||
gm_debug_msg(DEBUG_MCP, "GmMcpSession.HandleOpen: mcp server version "
|
||||
"does not match client version!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,8 +372,8 @@ gm_mcp_session_create_package(GmMcpSession *session, GmMcpPackageClass *klass,
|
|||
package);
|
||||
return package;
|
||||
} else {
|
||||
gm_debug_msg(DEBUG_MCP, "GmMcpSession.CreatePackage: package (%s) is already "
|
||||
"registered for %s", klass->name,
|
||||
gm_debug_msg(DEBUG_MCP, "GmMcpSession.CreatePackage: package (%s) is "
|
||||
"already registered for %s", klass->name,
|
||||
gm_options_get(gm_world_options(session->priv->world), "name"));
|
||||
return NULL;
|
||||
}
|
||||
|
@ -463,6 +465,8 @@ gm_mcp_session_handle_oob(GmMcpSession *session, gchar *line) {
|
|||
|
||||
gm_mcp_package_handle_simple(package, suffix,
|
||||
info.fields);
|
||||
} else {
|
||||
gm_debug_msg(DEBUG_MCP, "GmMcpSession.HandleOob: can't handle simple message!");
|
||||
}
|
||||
} else {
|
||||
gm_debug_msg(DEBUG_MCP, "GmMcpSession.HandleOob: unsupported package "
|
||||
|
@ -491,3 +495,7 @@ gm_mcp_session_handle_oob(GmMcpSession *session, gchar *line) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
GObject *gm_mcp_session_world(GmMcpSession *session) {
|
||||
return G_OBJECT(session->priv->world);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ G_BEGIN_DECLS
|
|||
GM_TYPE_MCP_SESSION))
|
||||
#define GM_MCP_SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), \
|
||||
GM_TYPE_MCP_SESSION, GmMcpSessionClass))
|
||||
#define GM_MCP_SESSION_WORLD(obj) (GM_WORLD(gm_mcp_session_world(obj)))
|
||||
|
||||
typedef struct _McpMultilineInfo {
|
||||
gchar *key;
|
||||
|
@ -64,6 +65,7 @@ struct _GmMcpSessionClass {
|
|||
GType gm_mcp_session_get_type(void) G_GNUC_CONST;
|
||||
GmMcpSession *gm_mcp_session_new(GObject *world);
|
||||
|
||||
GObject *gm_mcp_session_world(GmMcpSession *session);
|
||||
GList const *gm_mcp_session_get_packages(GmMcpSession *session);
|
||||
void gm_mcp_session_handle_oob(GmMcpSession *session, gchar *line);
|
||||
|
||||
|
|
Reference in New Issue