/* **************************************************************************** * * AttributeList::clone - */ void AttributeList::clone(AttributeList& aList) { for (unsigned int ix = 0; ix < aList.size(); ++ix) { push_back(aList[ix]); } }
/* **************************************************************************** * * includedAttribute - * * FIXME: note that in the current implementation, in which we only use 'name' to * compare, this function is equal to the one for ContextRegistrationAttrribute. * However, we keep them separated, as isDomain (present in ContextRegistrationAttribute * but not in ContextRegistration could mean a difference). To review once domain attributes * get implemented. * */ static bool includedAttribute(const ContextAttribute& attr, const AttributeList& attrsV) { // // This is the case in which the queryContextRequest doesn't include attributes, // so all the attributes are included in the response // if (attrsV.size() == 0) { return true; } for (unsigned int ix = 0; ix < attrsV.size(); ++ix) { if (attrsV[ix] == attr.name) { return true; } } return false; }
void Share::XMLFileListHandler::startElement(const char*, const char* localName, const char*, AttributeList list) { if (strcasecmp(localName, "FileListing") == 0) { if (currentDir) onProblem(); currentDir = root; } else if (strcasecmp(localName, "Directory") == 0) { if (!currentDir) { onProblem(); return; } // Add Directory to the currentDir. const char* name = 0; for (size_t n = 0; n < list.size(); n++) { if (strcasecmp(list[n].first, "Name") == 0) name = list[n].second; } if (name) { RemoteDir* dir = new RemoteDir(name, currentDir); currentDir = dir; } } else if (strcasecmp(localName, "File") == 0) { if (!currentDir) { onProblem(); return; } const char* name = 0; const char* tth = 0; uint64_t size = 0; for (size_t n = 0; n < list.size(); n++) { if (strcasecmp(list[n].first, "Name") == 0) name = list[n].second; else if (strcasecmp(list[n].first, "TTH") == 0) tth = list[n].second; else if (strcasecmp(list[n].first, "Size") == 0) size = quickdc_atoull(list[n].second); } if (name && tth) new Share::RemoteFile(name, size, tth, currentDir); } }
retval_t ScimBridgeAgentClientListenerImpl::set_preedit_attributes (scim_bridge_imcontext_id_t imcontext_id, const AttributeList &attributes) { scim_bridge_pdebugln (6, "set_preedit_attributes ()"); ScimBridgeMessage *message = scim_bridge_alloc_message (SCIM_BRIDGE_MESSAGE_SET_PREEDIT_ATTRIBUTES, attributes.size () * 4 + 1); char *imcontext_id_str; scim_bridge_string_from_uint (&imcontext_id_str, imcontext_id); scim_bridge_message_set_argument (message, 0, imcontext_id_str); free (imcontext_id_str); int arg_index = 1; for (AttributeList::const_iterator i = attributes.begin (); i != attributes.end (); ++i) { const Attribute &attribute = *i; char *begin_str; char *end_str; scim_bridge_string_from_uint (&begin_str, attribute.get_start ()); scim_bridge_string_from_uint (&end_str, attribute.get_end ()); const char *type_str; const char *value_str; if (attribute.get_type () == SCIM_ATTR_DECORATE) { type_str = SCIM_BRIDGE_MESSAGE_DECORATE; switch (attribute.get_value ()) { case SCIM_ATTR_DECORATE_UNDERLINE: value_str = SCIM_BRIDGE_MESSAGE_UNDERLINE; break; case SCIM_ATTR_DECORATE_REVERSE: value_str = SCIM_BRIDGE_MESSAGE_REVERSE; break; case SCIM_ATTR_DECORATE_HIGHLIGHT: value_str = SCIM_BRIDGE_MESSAGE_HIGHLIGHT; break; default: type_str = SCIM_BRIDGE_MESSAGE_NONE; value_str = SCIM_BRIDGE_MESSAGE_NONE; } } else if (attribute.get_type () == SCIM_ATTR_FOREGROUND || attribute.get_type () == SCIM_ATTR_BACKGROUND) { if (attribute.get_type () == SCIM_ATTR_FOREGROUND) { type_str = SCIM_BRIDGE_MESSAGE_FOREGROUND; } else { type_str = SCIM_BRIDGE_MESSAGE_BACKGROUND; } char *tmp_str = static_cast<char*> (alloca (sizeof (char) * (strlen (SCIM_BRIDGE_MESSAGE_COLOR) + 7))); value_str = tmp_str; strcpy (tmp_str, SCIM_BRIDGE_MESSAGE_COLOR); char *color_str = tmp_str + sizeof (char) * strlen (SCIM_BRIDGE_MESSAGE_COLOR); color_str[6] = '\0'; const char chars[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; for (unsigned int k = 0; k < 6; ++k) { const unsigned int digit_index = (attribute.get_value () >> (k * 4)) % 0x10; color_str[5 - k] = chars[digit_index]; } } else { type_str = SCIM_BRIDGE_MESSAGE_NONE; value_str = SCIM_BRIDGE_MESSAGE_NONE; } scim_bridge_message_set_argument (message, arg_index + 0, begin_str); scim_bridge_message_set_argument (message, arg_index + 1, end_str); scim_bridge_message_set_argument (message, arg_index + 2, type_str); scim_bridge_message_set_argument (message, arg_index + 3, value_str); free (begin_str); free (end_str); arg_index += 4; }