static void download_banner(GtChannel* self) { GtChannelPrivate* priv = gt_channel_get_instance_private(self); if (priv->video_banner_url) { GdkPixbuf* banner = NULL; if (!g_file_test(priv->cache_filename, G_FILE_TEST_EXISTS)) g_info("{GtChannel} Cache miss for channel '%s'", priv->name); else { g_info("{GtChannel} Cache hit for channel '%s'", priv->name); banner = gdk_pixbuf_new_from_file(priv->cache_filename, NULL); priv->cache_timestamp = utils_timestamp_file(priv->cache_filename); } if (!banner) gt_twitch_download_picture_async(main_app->twitch, priv->video_banner_url, 0, priv->cancel, download_banner_cb, self); else { g_thread_pool_push(cache_update_pool, self, NULL); set_banner(self, banner, FALSE, TRUE); priv->updating = FALSE; g_object_notify_by_pspec(G_OBJECT(self), props[PROP_UPDATING]); } } else { set_banner(self, gdk_pixbuf_new_from_resource("/com/gnome-twitch/icons/offline.png", NULL), FALSE, TRUE); priv->updating = FALSE; g_object_notify_by_pspec(G_OBJECT(self), props[PROP_UPDATING]); } }
static void cache_update_cb(gpointer data, gpointer udata) { if(!GT_IS_CHANNEL(data)) // We were probably unrefed during wait time. return; GtChannel* self = GT_CHANNEL(data); GtChannelPrivate* priv = gt_channel_get_instance_private(self); GdkPixbuf* pic = gt_twitch_download_picture(main_app->twitch, priv->video_banner_url, priv->cache_timestamp); if (pic) { set_banner(self, pic, TRUE, FALSE); g_info("{GtChannel} Updated cache entry for channel '%s'", priv->name); } }
static void download_banner_cb(GObject* source, GAsyncResult* res, gpointer udata) { GError* error = NULL; GdkPixbuf* pic = g_task_propagate_pointer(G_TASK(res), &error); if (error) { g_error_free(error); return; } GtChannel* self = GT_CHANNEL(udata); GtChannelPrivate* priv = gt_channel_get_instance_private(self); set_banner(self, pic, TRUE, TRUE); priv->updating = FALSE; g_object_notify_by_pspec(G_OBJECT(self), props[PROP_UPDATING]); }
PyErr_Format(PYLIBSSH2_Error, "Failure establishing startup %i: %s", rc, errmsg); return NULL; } } self->opened = 1; Py_INCREF(Py_None); return Py_None; } /* }}} */ /* {{{ PYLIBSSH2_Session_set_banner */ static char PYLIBSSH2_Session_set_banner_doc[] = "\ set_banner(banner)\n\ \n\ Sets the banner that will be sent to remote host.\n\ This is optional, the banner libssh2.DEFAULT_BANNER will be sent by default.\n\ \n\ @param banner: an user defined banner\n\ @type banner: str\n"; static PyObject * PYLIBSSH2_Session_set_banner(PYLIBSSH2_SESSION *self, PyObject *args) { PRINTFUNCNAME int rc; char *banner = LIBSSH2_SSH_DEFAULT_BANNER"_Python"; if (!PyArg_ParseTuple(args, "|s:set_banner", &banner)) { return NULL;
void prepare_script_env(struct openconnect_info *vpninfo) { if (vpninfo->ip_info.gateway_addr) script_setenv(vpninfo, "VPNGATEWAY", vpninfo->ip_info.gateway_addr, 0); set_banner(vpninfo); script_setenv(vpninfo, "CISCO_SPLIT_INC", NULL, 0); script_setenv(vpninfo, "CISCO_SPLIT_EXC", NULL, 0); script_setenv_int(vpninfo, "INTERNAL_IP4_MTU", vpninfo->ip_info.mtu); if (vpninfo->ip_info.addr) { script_setenv(vpninfo, "INTERNAL_IP4_ADDRESS", vpninfo->ip_info.addr, 0); if (vpninfo->ip_info.netmask) { struct in_addr addr; struct in_addr mask; if (inet_aton(vpninfo->ip_info.addr, &addr) && inet_aton(vpninfo->ip_info.netmask, &mask)) { char *netaddr; addr.s_addr &= mask.s_addr; netaddr = inet_ntoa(addr); script_setenv(vpninfo, "INTERNAL_IP4_NETADDR", netaddr, 0); script_setenv(vpninfo, "INTERNAL_IP4_NETMASK", vpninfo->ip_info.netmask, 0); script_setenv_int(vpninfo, "INTERNAL_IP4_NETMASKLEN", netmasklen(mask)); } } } if (vpninfo->ip_info.addr6) { script_setenv(vpninfo, "INTERNAL_IP6_ADDRESS", vpninfo->ip_info.addr6, 0); script_setenv(vpninfo, "INTERNAL_IP6_NETMASK", vpninfo->ip_info.netmask6, 0); } else if (vpninfo->ip_info.netmask6) { char *slash = strchr(vpninfo->ip_info.netmask6, '/'); script_setenv(vpninfo, "INTERNAL_IP6_NETMASK", vpninfo->ip_info.netmask6, 0); if (slash) { *slash = 0; script_setenv(vpninfo, "INTERNAL_IP6_ADDRESS", vpninfo->ip_info.netmask6, 0); *slash = '/'; } } if (vpninfo->ip_info.dns[0]) script_setenv(vpninfo, "INTERNAL_IP4_DNS", vpninfo->ip_info.dns[0], 0); else script_setenv(vpninfo, "INTERNAL_IP4_DNS", NULL, 0); if (vpninfo->ip_info.dns[1]) script_setenv(vpninfo, "INTERNAL_IP4_DNS", vpninfo->ip_info.dns[1], 1); if (vpninfo->ip_info.dns[2]) script_setenv(vpninfo, "INTERNAL_IP4_DNS", vpninfo->ip_info.dns[2], 1); if (vpninfo->ip_info.nbns[0]) script_setenv(vpninfo, "INTERNAL_IP4_NBNS", vpninfo->ip_info.nbns[0], 0); else script_setenv(vpninfo, "INTERNAL_IP4_NBNS", NULL, 0); if (vpninfo->ip_info.nbns[1]) script_setenv(vpninfo, "INTERNAL_IP4_NBNS", vpninfo->ip_info.nbns[1], 1); if (vpninfo->ip_info.nbns[2]) script_setenv(vpninfo, "INTERNAL_IP4_NBNS", vpninfo->ip_info.nbns[2], 1); if (vpninfo->ip_info.domain) script_setenv(vpninfo, "CISCO_DEF_DOMAIN", vpninfo->ip_info.domain, 0); else script_setenv(vpninfo, "CISCO_DEF_DOMAIN", NULL, 0); if (vpninfo->ip_info.proxy_pac) script_setenv(vpninfo, "CISCO_PROXY_PAC", vpninfo->ip_info.proxy_pac, 0); if (vpninfo->ip_info.split_dns) { char *list; int len = 0; struct oc_split_include *dns = vpninfo->ip_info.split_dns; while (dns) { len += strlen(dns->route) + 1; dns = dns->next; } list = malloc(len); if (list) { char *p = list; dns = vpninfo->ip_info.split_dns; while (1) { strcpy(p, dns->route); p += strlen(p); dns = dns->next; if (!dns) break; *(p++) = ','; } script_setenv(vpninfo, "CISCO_SPLIT_DNS", list, 0); free(list); } } if (vpninfo->ip_info.split_includes) { struct oc_split_include *this = vpninfo->ip_info.split_includes; int nr_split_includes = 0; int nr_v6_split_includes = 0; while (this) { process_split_xxclude(vpninfo, 1, this->route, &nr_split_includes, &nr_v6_split_includes); this = this->next; } if (nr_split_includes) script_setenv_int(vpninfo, "CISCO_SPLIT_INC", nr_split_includes); if (nr_v6_split_includes) script_setenv_int(vpninfo, "CISCO_IPV6_SPLIT_INC", nr_v6_split_includes); } if (vpninfo->ip_info.split_excludes) { struct oc_split_include *this = vpninfo->ip_info.split_excludes; int nr_split_excludes = 0; int nr_v6_split_excludes = 0; while (this) { process_split_xxclude(vpninfo, 0, this->route, &nr_split_excludes, &nr_v6_split_excludes); this = this->next; } if (nr_split_excludes) script_setenv_int(vpninfo, "CISCO_SPLIT_EXC", nr_split_excludes); if (nr_v6_split_excludes) script_setenv_int(vpninfo, "CISCO_IPV6_SPLIT_EXC", nr_v6_split_excludes); } setenv_cstp_opts(vpninfo); }