const char *FindVersion(int file_id, BYTE *pbVersionBytes, int cpbVersionBytes, const Category cat) {

	if(!doc[cat]) return 0;

	char version_string[128];
	strncpy(version_string, (char *)pbVersionBytes, cpbVersionBytes);
	version_string[sizeof(version_string)-1] = 0;

	ezxml_t root = ezxml_get(doc[cat], "channel", 0, "item", -1);
    while (root) {
        int id = atoi(ezxml_txt(ezxml_child(root, "id")));
        const char* version = ezxml_txt(ezxml_child(root, "version"));
        
		if (id == file_id && version[0]) {
			if (strncmp(version, (char*)pbVersionBytes, cpbVersionBytes) && VersionLess(version_string, version)) {
				return version;
			} else {
				return "same";
            }
		} 

        root = ezxml_next(root);
    }

	return 0;
}
Exemple #2
0
/* ------------------------------------------------------------------------- */
int Reg_Get(Reg_TRegistry* reg, const ezxml_t keys, ezxml_t items)
{
    ezxml_t key;

    assert(reg);

    key = keys->child;
    if (key)
    {
        do
        {
            ezxml_t item;
            if ((item = ezxml_child(reg->m_root, ezxml_txt(key))) &&
                            ezxml_name(item))
            {
                ezxml_t child = ezxml_add_child_d(items, ezxml_name(item), 0);
                ezxml_set_txt_d(child, ezxml_txt(item));
            }
        } while((key = key->ordered));
    }
    else
    {
        ezxml_t item = reg->m_root->child;
        while(item)
        {
            ezxml_t child = ezxml_add_child_d(items, ezxml_name(item), 0);
            ezxml_set_txt_d(child, ezxml_txt(item));

            item = item->ordered;
        }
    }

    return -EXIT_SUCCESS;
}
Exemple #3
0
bool CMsnProto::MSN_StoreCreateProfile(bool allowRecurse)
{
    char* reqHdr;
    ezxml_t tbdy;
    ezxml_t xmlp = storeSoapHdr("CreateProfile", "RoamingSeed", tbdy, reqHdr);

    ezxml_t pro = ezxml_add_child(tbdy, "profile", 0);
    ezxml_t node;

    pro = ezxml_add_child(pro, "ExpressionProfile", 0);
    ezxml_add_child(pro, "PersonalStatus", 0);
    node = ezxml_add_child(pro, "RoleDefinitionName", 0);
    ezxml_set_txt(node, "ExpressionProfileDefault");

    char* szData = ezxml_toxml(xmlp, true);

    ezxml_free(xmlp);

    unsigned status = 0;
    char *storeUrl, *tResult = NULL;

    storeUrl = mir_strdup("https://storage.msn.com/storageservice/SchematizedStore.asmx");
    tResult = getSslResult(&storeUrl, szData, reqHdr, status);

    mir_free(reqHdr);
    free(szData);

    if (tResult != NULL)
    {
        if (status == 200)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            UpdateStoreCacheKey(xmlm);
            ezxml_t body = getSoapResponse(xmlm, "CreateProfile");

            MSN_StoreShareItem(ezxml_txt(body));
            MSN_SharingMyProfile();

            ezxml_free(xmlm);
        }
        else if (status == 500)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            const char* szErr = ezxml_txt(getSoapFault(xmlm, true));
            if (strcmp(szErr, "PassportAuthFail") == 0 && allowRecurse)
            {
                MSN_GetPassportAuth();
                status = MSN_StoreCreateProfile(false) ? 200 : 500;
            }
            ezxml_free(xmlm);
        }
    }

    mir_free(tResult);
    mir_free(storeUrl);

    return status == 200;
}
Exemple #4
0
/*	get text from <value> nodes; some of them have <boolean>, <string>
 *	or <int> subnodes, just ignore them
 *	@param xml node <value>
 */
static char *PianoXmlGetNodeText (const ezxml_t node) {
	char *retTxt = NULL;

	retTxt = ezxml_txt (node);
	/* no text => empty string */
	if (*retTxt == '\0') {
		retTxt = ezxml_txt (node->child);
	}
	return retTxt;
}
Exemple #5
0
API_REGISTER_METHOD( wlan, getClientList, EWF_HTTP_REQUEST_METHOD_GET, API_ACCESS_POLICY_PRIVATE )
{
        char ipaddr[NBU_NET_SIZEOF_IPADDR];
        int ret;

        int n = 0;

        char *buf_xml = NULL;
        size_t buf_xml_size;
	ezxml_t xmln_root, xmln_mac;

	ret = nbd_wlan_list_assoc(NULL, 
                                  &buf_xml, 
                                  &buf_xml_size);

        if(ret == NBD_SUCCESS)
        {
                xmln_root = ezxml_parse_str(buf_xml, buf_xml_size);
                if(xmln_root != NULL)
                {
                        n = 0;
                        
                        for(xmln_mac = ezxml_get(xmln_root, 
                                                 "assoclist", 
                                                 0, "mac", -1); 
                            xmln_mac; 
                            xmln_mac = xmln_mac->next)
                        {
                                ++n;
                                
                                nbu_string_printf( buffer, sizeof buffer, "wlan.clients.%d.mac_addr", n );
                                api_set_value(buffer, ezxml_txt(xmln_mac));

                                if(nbd_lan_mac2ip(ezxml_txt(xmln_mac), 
                                                  ipaddr, 
                                                  sizeof(ipaddr)) != NBD_SUCCESS)
                                {
                                        ipaddr[0] = '\0';
                                }
                                
                                nbu_string_printf( buffer, sizeof buffer, "wlan.clients.%d.ip_addr", n );
                                api_set_value( buffer, ipaddr );
                        }
                        
                        ezxml_free(xmln_root);
                }
                        
                free(buf_xml);
        }
}
Exemple #6
0
bool CMsnProto::MSN_StoreCreateRelationships(bool allowRecurse)
{
    char* reqHdr;
    ezxml_t tbdy;
    ezxml_t xmlp = storeSoapHdr("CreateRelationships", "RoamingIdentityChanged", tbdy, reqHdr);

    ezxml_t rels = ezxml_add_child(tbdy, "relationships", 0);
    ezxml_t rel = ezxml_add_child(rels, "Relationship", 0);
    ezxml_t node = ezxml_add_child(rel, "SourceID", 0);
    ezxml_set_txt(node, expresid);
    node = ezxml_add_child(rel, "SourceType", 0);
    ezxml_set_txt(node, "SubProfile");
    node = ezxml_add_child(rel, "TargetID", 0);
    ezxml_set_txt(node, photoid);
    node = ezxml_add_child(rel, "TargetType", 0);
    ezxml_set_txt(node, "Photo");
    node = ezxml_add_child(rel, "RelationshipName", 0);
    ezxml_set_txt(node, "ProfilePhoto");

    char* szData = ezxml_toxml(xmlp, true);

    ezxml_free(xmlp);

    unsigned status = 0;
    char *storeUrl = NULL, *tResult = NULL;

    for (int k = 4; --k;)
    {
        mir_free(storeUrl);
        storeUrl = GetStoreHost("CreateRelationships");
        tResult = getSslResult(&storeUrl, szData, reqHdr, status);
        if (tResult == NULL) UpdateStoreHost("CreateRelationships", NULL);
        else break;
    }

    mir_free(reqHdr);
    free(szData);

    if (tResult != NULL)
    {
        UpdateStoreHost("CreateRelationships", storeUrl);

        if (status == 500)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            const char* szErr = ezxml_txt(getSoapFault(xmlm, true));
            if (strcmp(szErr, "PassportAuthFail") == 0 && allowRecurse)
            {
                MSN_GetPassportAuth();
                status = MSN_StoreCreateRelationships(false) ? 200 : 500;
            }
            ezxml_free(xmlm);
        }
    }

    mir_free(tResult);
    mir_free(storeUrl);

    return status == 200;
}
Exemple #7
0
int inTSendRecvAPDU(BYTE *bSendData, int inSendLen, BYTE *bRecvData, int * inRecvLen, int inTimeOut, STR * TESTACTIONNAME, int Outputlen,BOOL saved) {
    int inRetVal;


    if(saved==TRUE) myDebugFile((char*)__FUNCTION__,__LINE__,"Cmd:%s start",TESTACTIONNAME);
    memset(cOutputData, 0x00, sizeof(cOutputData));
    
    if ((gScrpitTesting == 1) && (ezxml_get(gTestAction, TESTACTIONNAME, -1) != NULL)) {
        ezxml_t APDURESP = ezxml_get(gTestAction, TESTACTIONNAME, -1);
        BYTE *strbuf = ezxml_txt(APDURESP);
        int len = strlen(strbuf);

        if (strcmp(strbuf, "default") == 0) {
            memset(cOutputData, 0x00, Outputlen);
            cOutputData[2] = sizeof (Outputlen);
            cOutputData[cOutputData[2] + 1] = 0x90;
            cOutputData[cOutputData[2] + 2] = 0x00;
        } else {
            wub_str_2_hex(strbuf, cOutputData, len);
        }
        // ezxml_free(APDURESP);
        return SUCCESS;
    } else {
        inRetVal = inSendRecvAPDU(bSendData, inSendLen, bRecvData, inRecvLen, inTimeOut, saved);
        
        //myDebugFile((char*)__FUNCTION__,__LINE__,"Cmd:%s end result(%d)",TESTACTIONNAME,inRetVal);
        //printf("[%s,%d] inSendRecvAPDU result(%04X)\n",__FUNCTION__,__LINE__, inRetVal);
        if (inRetVal != SUCCESS) {
            return inRetVal;
        }
        return SUCCESS;
    }

}
int FindFileID(const char *name, const Category cat, UpdateList *update_list) 
{
	if (!doc[cat]) return -1;

	if (update_list) 
    {
		// couldn't find it in xml file - check if a plugin gave us a file id for a different shortName
		for (int i = 0; i < update_list->getCount(); ++i) 
        {
			UpdateInternal &ui = (*update_list)[i];
			if (ui.file_id != -1 && strcmp(ui.update.szComponentName, name) == 0) 
				return ui.file_id;
		}
	}

	// ignore case in name
	int id = -1;
	char *version = NULL;

	ezxml_t root = ezxml_get(doc[cat], "channel", 0, "item", -1);
    while (root) 
	{
        const char* title = ezxml_txt(ezxml_child(root, "title"));
        if (_stricmp(title, name) == 0) 
		{
            const char* subcategory = ezxml_txt(ezxml_child(root, "subcategory"));
            if (strcmp(subcategory, "Archived")) 
			{
                int id1 = atoi(ezxml_txt(ezxml_child(root, "id")));
                if (id1)
				{
					char *version1 = ezxml_txt(ezxml_child(root, "version"));
					if (!version || (version1 && VersionLess(version, version1)))
					{
						version = version1;
						id = id1;
					}
				}
            }
        }
        root = ezxml_next(root);
    }

	return id;
}
Exemple #9
0
void CMsnProto::processMailData(char* mailData)
{
	if (mir_strcmp(mailData, "too-large") == 0) {
		getMetaData();
	}
	else {
		ezxml_t xmli = ezxml_parse_str(mailData, mir_strlen(mailData));

		ezxml_t toke = ezxml_child(xmli, "E");

		const char* szIU = ezxml_txt(ezxml_child(toke, "IU"));
		if (*szIU) mUnreadMessages = atol(szIU);

		const char* szOU = ezxml_txt(ezxml_child(toke, "OU"));
		if (*szOU) mUnreadJunkEmails = atol(szOU);

		getOIMs(xmli);

		ezxml_free(xmli);
	}
}
Exemple #10
0
/* ------------------------------------------------------------------------- */
int Reg_Update(Reg_TRegistry* reg, const ezxml_t items)
{
    ezxml_t new_item;

    assert(reg);

    /* sanity check */
    if (!(new_item = items->child))
        return -EXIT_SUCCESS;
    while(new_item)
    {
        if ('\0' == ezxml_txt(new_item)[0])
            return -EXIT_FAILURE;

        new_item = new_item->ordered;
    }

    /* update */
    new_item = items->child;
    while(new_item)
    {
        ezxml_t existing_item;

        if ((existing_item = ezxml_child(reg->m_root, ezxml_name(new_item))))
            ezxml_set_txt_d(existing_item, ezxml_txt(new_item));
        else
        {
            ezxml_t n = ezxml_add_child_d(reg->m_root, ezxml_name(new_item), 0);
            ezxml_set_txt_d(n, ezxml_txt(new_item));
        }
        ezxml_remove(new_item);

        new_item = items->child;
    }

    if (reg->m_file_name)
        Reg_ExportToFile(reg, reg->m_file_name);

    return -EXIT_SUCCESS;
}
Exemple #11
0
/*	parses "why did you play ...?" answer
 *	@param xml
 *	@param returns the answer
 *	@return _OK or error
 */
PianoReturn_t PianoXmlParseNarrative (char *xml, char **retNarrative) {
	ezxml_t xmlDoc, dataNode;
	PianoReturn_t ret;

	if ((ret = PianoXmlInitDoc (xml, &xmlDoc)) != PIANO_RET_OK) {
		return ret;
	}

	/* <methodResponse> <params> <param> <value> $textnode */
	dataNode = ezxml_get (xmlDoc, "params", 0, "param", 0, "value", -1);
	*retNarrative = strdup (ezxml_txt (dataNode));

	ezxml_free (xmlDoc);

	return ret;
}
Exemple #12
0
/*	parse simple answers like this: <?xml version="1.0" encoding="UTF-8"?>
 *	<methodResponse><params><param><value>1</value></param></params>
 *	</methodResponse>
 *	@param xml string
 *	@return
 */
PianoReturn_t PianoXmlParseSimple (char *xml) {
	ezxml_t xmlDoc, dataNode;
	PianoReturn_t ret;

	if ((ret = PianoXmlInitDoc (xml, &xmlDoc)) != PIANO_RET_OK) {
		return ret;
	}

	dataNode = ezxml_get (xmlDoc, "params", 0, "param", 0, "value", -1);

	if (strcmp (ezxml_txt (dataNode), "1") == 0) {
		ret = PIANO_RET_OK;
	} else {
		ret = PIANO_RET_ERR;
	}

	ezxml_free (xmlDoc);

	return ret;
}
Exemple #13
0
bool CMsnProto::MSN_StoreShareItem(const char* id, bool allowRecurse)
{
    char* reqHdr;
    ezxml_t tbdy;
    ezxml_t xmlp = storeSoapHdr("ShareItem", "RoamingSeed", tbdy, reqHdr);

    ezxml_t node = ezxml_add_child(tbdy, "resourceID", 0);
    ezxml_set_txt(node, id);
    node = ezxml_add_child(tbdy, "displayName", 0);
    ezxml_set_txt(node, "Messenger Roaming Identity");

    char* szData = ezxml_toxml(xmlp, true);

    ezxml_free(xmlp);

    unsigned status = 0;
    char *storeUrl, *tResult = NULL;

    storeUrl = mir_strdup("https://storage.msn.com/storageservice/SchematizedStore.asmx");
    tResult = getSslResult(&storeUrl, szData, reqHdr, status);

    mir_free(reqHdr);
    free(szData);

    if (tResult != NULL && status == 500)
    {
        ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
        const char* szErr = ezxml_txt(getSoapFault(xmlm, true));
        if (strcmp(szErr, "PassportAuthFail") == 0 && allowRecurse)
        {
            MSN_GetPassportAuth();
            status = MSN_StoreCreateProfile(false) ? 200 : 500;
        }
        ezxml_free(xmlm);
    }

    mir_free(tResult);
    mir_free(storeUrl);

    return status == 200;
}
void LCOrbitsAnaOctahedron::config(ezxml_t xmlbloc)
{
	configBase(xmlbloc);
	ezxml_t param;
	for(param = ezxml_child(xmlbloc,"Param"); param; param = param->next){
		if(strcmp(ezxml_attr(param,"Name"),"Armlength")==0){
			L0m = MT->gXMLLength(param);
		}
		if(strcmp(ezxml_attr(param,"Name"),"OrderDelay")==0){
			OrderArm = atoi(ezxml_txt(param));
		}
		if(strcmp(ezxml_attr(param,"Name"),"OrbitApproximation")==0){
			char * tmpStr(NULL);
			MT->stripcopy((*param).txt, tmpStr);
			
			if(MT->wcmp(tmpStr,"Static"))
				move = 0;
			if(MT->wcmp(tmpStr,"Moving"))
				move = 1;
			if(tmpStr != NULL)
				MT->Free(tmpStr, (strlen(tmpStr)+1) * sizeof(char));
		}
		if(strcmp(ezxml_attr(param,"Name"),"OffsetSC1")==0){
			pSCOff[0] = atof(ezxml_txt(param));
		}
		if(strcmp(ezxml_attr(param,"Name"),"OffsetSC2")==0){
			pSCOff[1] = atof(ezxml_txt(param));
		}
		if(strcmp(ezxml_attr(param,"Name"),"OffsetSC3")==0){
			pSCOff[2] = atof(ezxml_txt(param));
		}
		if(strcmp(ezxml_attr(param,"Name"),"OffsetSC4")==0){
			pSCOff[3] = atof(ezxml_txt(param));
		}
		if(strcmp(ezxml_attr(param,"Name"),"OffsetSC5")==0){
			pSCOff[4] = atof(ezxml_txt(param));
		}
		if(strcmp(ezxml_attr(param,"Name"),"OffsetSC6")==0){
			pSCOff[5] = atof(ezxml_txt(param));
		}
	}
}
Exemple #15
0
/*	parses things like this:
 *	<struct>
 *		<member>
 *			<name />
 *			<value />
 *		</member>
 *		<!-- ... -->
 *	</struct>
 *	@param xml node named "struct" (or containing a similar structure)
 *	@param who wants to use this data? callback: content of <name> as
 *			string, content of <value> as xmlNode (may contain other nodes
 *			or text), additional data used by callback(); don't forget
 *			to *copy* data taken from <name> or <value> as they will be
 *			freed soon
 *	@param extra data for callback
 */
static void PianoXmlStructParser (const ezxml_t structRoot,
		void (*callback) (const char *, const ezxml_t, void *), void *data) {
	ezxml_t curNode, keyNode, valueNode;
	char *key;

	/* get all <member> nodes */
    for (curNode = ezxml_child (structRoot, "member"); curNode; curNode = curNode->next) {
		/* reset variables */
		key = NULL;
		valueNode = keyNode = NULL;

		keyNode = ezxml_child (curNode, "name");
		if (keyNode != NULL) {
			key = ezxml_txt (keyNode);
		}

		valueNode = ezxml_child (curNode, "value");
		/* this will ignore empty <value /> nodes, but well... */
		if (*key != '\0' && valueNode != NULL) {
			(*callback) ((char *) key, valueNode, data);
		}
	}
}
Exemple #16
0
void CMsnProto::UpdateStoreCacheKey(ezxml_t bdy)
{
    ezxml_t key = ezxml_get(bdy, "soap:Header", 0, "AffinityCacheHeader", 0, "CacheKey", -1);
    if (key) replaceStr(storageCacheKey, ezxml_txt(key));
}
Exemple #17
0
bool CMsnProto::MSN_StoreFindDocuments(bool allowRecurse)
{
    char* reqHdr;
    ezxml_t tbdy;
    ezxml_t xmlp = storeSoapHdr("FindDocuments", "RoamingIdentityChanged", tbdy, reqHdr);

    ezxml_t srch = ezxml_add_child(tbdy, "objectHandle", 0);
    ezxml_t node = ezxml_add_child(srch, "RelationshipName", 0);
    ezxml_set_txt(node, "/UserTiles");

    ezxml_t alias = ezxml_add_child(srch, "Alias", 0);
    node = ezxml_add_child(alias, "Name", 0);
    ezxml_set_txt(node, mycid);
    node = ezxml_add_child(alias, "NameSpace", 0);
    ezxml_set_txt(node, "MyCidStuff");

    ezxml_t doc = ezxml_add_child(tbdy, "documentAttributes", 0);
    node = ezxml_add_child(doc, "ResourceID", 0);
    ezxml_set_txt(node, "true");
    node = ezxml_add_child(doc, "Name", 0);
    ezxml_set_txt(node, "true");

    doc = ezxml_add_child(tbdy, "documentFilter", 0);
    node = ezxml_add_child(doc, "FilterAttributes", 0);
    ezxml_set_txt(node, "None");

    doc = ezxml_add_child(tbdy, "documentSort", 0);
    node = ezxml_add_child(doc, "SortBy", 0);
    ezxml_set_txt(node, "DateModified");

    doc = ezxml_add_child(tbdy, "findContext", 0);
    node = ezxml_add_child(doc, "FindMethod", 0);
    ezxml_set_txt(node, "Default");
    node = ezxml_add_child(doc, "ChunkSize", 0);
    ezxml_set_txt(node, "25");

    char* szData = ezxml_toxml(xmlp, true);

    ezxml_free(xmlp);

    unsigned status = 0;
    char *storeUrl = NULL, *tResult = NULL;

    for (int k = 4; --k;)
    {
        mir_free(storeUrl);
        storeUrl = GetStoreHost("FindDocuments");
        tResult = getSslResult(&storeUrl, szData, reqHdr, status);
        if (tResult == NULL) UpdateStoreHost("FindDocuments", NULL);
        else break;
    }

    mir_free(reqHdr);
    free(szData);

    if (tResult != NULL)
    {
        UpdateStoreHost("FindDocuments", storeUrl);
        if (status == 500)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            const char* szErr = ezxml_txt(getSoapFault(xmlm, true));
            if (strcmp(szErr, "PassportAuthFail") == 0 && allowRecurse)
            {
                MSN_GetPassportAuth();
                status = MSN_StoreFindDocuments(false) ? 200 : 500;
            }
            ezxml_free(xmlm);
        }
    }

    mir_free(tResult);
    mir_free(storeUrl);

    return status == 200;
}
Exemple #18
0
bool CMsnProto::MSN_StoreUpdateDocument(const TCHAR *sztName, const char *szMimeType, const char *szPicData, bool allowRecurse)
{
    char* reqHdr;
    char* szName = mir_utf8encodeT(sztName);
    ezxml_t tbdy;
    ezxml_t xmlp = storeSoapHdr("UpdateDocument", "RoamingIdentityChanged", tbdy, reqHdr);

    ezxml_t doc = ezxml_add_child(tbdy, "document", 0);
    ezxml_set_attr(doc, "xsi:type", "Photo");
    ezxml_t node = ezxml_add_child(doc, "ResourceID", 0);
    ezxml_set_txt(node, photoid);
    node = ezxml_add_child(doc, "Name", 0);
    ezxml_set_txt(node, szName);

    doc = ezxml_add_child(doc, "DocumentStreams", 0);
    doc = ezxml_add_child(doc, "DocumentStream", 0);
    ezxml_set_attr(doc, "xsi:type", "PhotoStream");

    node = ezxml_add_child(doc, "MimeType", 0);
    ezxml_set_txt(node, szMimeType);
    node = ezxml_add_child(doc, "Data", 0);
    ezxml_set_txt(node, szPicData);
    node = ezxml_add_child(doc, "DataSize", 0);
    ezxml_set_txt(node, "0");
    node = ezxml_add_child(doc, "DocumentStreamType", 0);
    ezxml_set_txt(node, "UserTileStatic");

    char* szData = ezxml_toxml(xmlp, true);

    ezxml_free(xmlp);
    mir_free(szName);

    unsigned status = 0;
    char *storeUrl = NULL, *tResult = NULL;

    for (int k = 4; --k;)
    {
        mir_free(storeUrl);
        storeUrl = GetStoreHost("UpdateDocument");
        tResult = getSslResult(&storeUrl, szData, reqHdr, status);
        if (tResult == NULL) UpdateStoreHost("UpdateDocument", NULL);
        else break;
    }

    mir_free(reqHdr);
    free(szData);

    if (tResult != NULL)
    {
        UpdateStoreHost("UpdateDocument", storeUrl);
        if (status == 500 && allowRecurse)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            const char* szErr = ezxml_txt(getSoapFault(xmlm, true));
            if (strcmp(szErr, "PassportAuthFail") == 0)
            {
                MSN_GetPassportAuth();
                status = MSN_StoreUpdateDocument(sztName, szMimeType, szPicData, false) ? 200 : 500;
            }
            else if (szErr[0])
            {
                MSN_StoreDeleteRelationships(true);
                MSN_StoreDeleteRelationships(false);

                MSN_StoreCreateDocument(sztName, szMimeType, szPicData);
                MSN_StoreCreateRelationships();
            }
            ezxml_free(xmlm);
        }
    }

    mir_free(tResult);
    mir_free(storeUrl);

    return status == 200;
}
Exemple #19
0
void CMsnProto::getOIMs(ezxml_t xmli)
{
	ezxml_t toki = ezxml_child(xmli, "M");
	if (toki == NULL) return;

	char* getReqHdr;
	ezxml_t reqmsg;
	ezxml_t xmlreq = oimRecvHdr("GetMessage", reqmsg, getReqHdr);

	ezxml_t reqmid = ezxml_add_child(reqmsg, "messageId", 0);
	ezxml_t reqmrk = ezxml_add_child(reqmsg, "alsoMarkAsRead", 0);
	ezxml_set_txt(reqmrk, "false");

	char* delReqHdr;
	ezxml_t delmsg;
	ezxml_t xmldel = oimRecvHdr("DeleteMessages", delmsg, delReqHdr);
	ezxml_t delmids = ezxml_add_child(delmsg, "messageIds", 0);

	while (toki != NULL) {
		const char* szId = ezxml_txt(ezxml_child(toki, "I"));
		const char* szEmail = ezxml_txt(ezxml_child(toki, "E"));

		ezxml_set_txt(reqmid, szId);
		char* szData = ezxml_toxml(xmlreq, true);

		unsigned status;
		char* url = (char*)mir_strdup(oimRecvUrl);

		char* tResult = getSslResult(&url, szData, getReqHdr, status);

		free(szData);
		mir_free(url);

		if (tResult != NULL && status == 200) {
			ezxml_t xmlm = ezxml_parse_str(tResult, mir_strlen(tResult));
			ezxml_t body = getSoapResponse(xmlm, "GetMessage");

			MimeHeaders mailInfo;
			const char* mailbody = mailInfo.readFromBuffer((char*)ezxml_txt(body));

			time_t evtm = time(NULL);
			const char* arrTime = mailInfo["X-OriginalArrivalTime"];
			if (arrTime != NULL) {
				char szTime[32], *p;
				txtParseParam(arrTime, "FILETIME", "[", "]", szTime, sizeof(szTime));

				unsigned filetimeLo = strtoul(szTime, &p, 16);
				if (*p == ':') {
					unsigned __int64 filetime = strtoul(p + 1, &p, 16);
					filetime <<= 32;
					filetime |= filetimeLo;
					filetime /= 10000000;
#ifndef __GNUC__
					filetime -= 11644473600ui64;
#else
					filetime -= 11644473600ull;
#endif
					evtm = (time_t)filetime;
				}
			}

			PROTORECVEVENT pre = { 0 };
			pre.szMessage = mailInfo.decodeMailBody((char*)mailbody);
			pre.timestamp = evtm;
			ProtoChainRecvMsg(MSN_HContactFromEmail(szEmail), &pre);
			mir_free(pre.szMessage);

			ezxml_t delmid = ezxml_add_child(delmids, "messageId", 0);
			ezxml_set_txt(delmid, szId);

			ezxml_free(xmlm);
		}
		mir_free(tResult);
		toki = ezxml_next(toki);
	}
	ezxml_free(xmlreq);
	mir_free(getReqHdr);

	if (ezxml_child(delmids, "messageId") != NULL) {
		char* szData = ezxml_toxml(xmldel, true);

		unsigned status;
		char* url = (char*)mir_strdup(oimRecvUrl);

		char* tResult = getSslResult(&url, szData, delReqHdr, status);

		mir_free(url);
		mir_free(tResult);
		free(szData);
	}
	ezxml_free(xmldel);
	mir_free(delReqHdr);
}
Exemple #20
0
/* Load a BSDF struct from the given file (free first and keep name) */
SDError
SDloadFile(SDData *sd, const char *fname)
{
	SDError		lastErr;
	ezxml_t		fl, wtl;

	if ((sd == NULL) | (fname == NULL || !*fname))
		return SDEargument;
				/* free old data, keeping name */
	SDfreeBSDF(sd);
				/* parse XML file */
	fl = ezxml_parse_file(fname);
	if (fl == NULL) {
		sprintf(SDerrorDetail, "Cannot open BSDF \"%s\"", fname);
		return SDEfile;
	}
	if (ezxml_error(fl)[0]) {
		sprintf(SDerrorDetail, "BSDF \"%s\" %s", fname, ezxml_error(fl));
		ezxml_free(fl);
		return SDEformat;
	}
	if (strcmp(ezxml_name(fl), "WindowElement")) {
		sprintf(SDerrorDetail,
			"BSDF \"%s\": top level node not 'WindowElement'",
				sd->name);
		ezxml_free(fl);
		return SDEformat;
	}
	wtl = ezxml_child(fl, "FileType");
	if (wtl != NULL && strcmp(ezxml_txt(wtl), "BSDF")) {
		sprintf(SDerrorDetail,
			"XML \"%s\": wrong FileType (must be 'BSDF')",
				sd->name);
		ezxml_free(fl);
		return SDEformat;
	}
	wtl = ezxml_child(ezxml_child(fl, "Optical"), "Layer");
	if (wtl == NULL) {
		sprintf(SDerrorDetail, "BSDF \"%s\": no optical layers'",
				sd->name);
		ezxml_free(fl);
		return SDEformat;
	}
				/* load geometry if present */
	lastErr = SDloadGeometry(sd, wtl);
	if (lastErr) {
		ezxml_free(fl);
		return lastErr;
	}
				/* try loading variable resolution data */
	lastErr = SDloadTre(sd, wtl);
				/* check our result */
	if (lastErr == SDEsupport)	/* try matrix BSDF if not tree data */
		lastErr = SDloadMtx(sd, wtl);
		
				/* done with XML file */
	ezxml_free(fl);
	
	if (lastErr) {		/* was there a load error? */
		SDfreeBSDF(sd);
		return lastErr;
	}
				/* remove any insignificant components */
	if (sd->rf != NULL && sd->rf->maxHemi <= .001) {
		SDfreeSpectralDF(sd->rf); sd->rf = NULL;
	}
	if (sd->rb != NULL && sd->rb->maxHemi <= .001) {
		SDfreeSpectralDF(sd->rb); sd->rb = NULL;
	}
	if (sd->tf != NULL && sd->tf->maxHemi <= .001) {
		SDfreeSpectralDF(sd->tf); sd->tf = NULL;
	}
	if (sd->tb != NULL && sd->tb->maxHemi <= .001) {
		SDfreeSpectralDF(sd->tb); sd->tb = NULL;
	}
				/* return success */
	return SDEnone;
}
Exemple #21
0
void CMsnProto::MSN_GCProcessThreadActivity(ezxml_t xmli, const TCHAR *mChatID)
{
	if (!mir_strcmp(xmli->name, "topicupdate")) {
		ezxml_t initiator = ezxml_child(xmli, "initiator");
		GCDEST gcd = { m_szModuleName, mChatID, GC_EVENT_TOPIC};
		GCEVENT gce = { sizeof(gce), &gcd };
		gce.dwFlags = GCEF_ADDTOLOG;
		gce.time = MsnTSToUnixtime(ezxml_txt(ezxml_child(xmli, "eventtime")));
		gce.ptszUID = initiator?mir_a2t(initiator->txt):NULL;
		MCONTACT hContInitiator = MSN_HContactFromEmail(initiator->txt);
		gce.ptszNick = GetContactNameT(hContInitiator);
		gce.ptszText = mir_a2t(ezxml_txt(ezxml_child(xmli, "value")));
		CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
		mir_free((TCHAR*)gce.ptszUID);
		mir_free((TCHAR*)gce.ptszText);
	}
	else if (ezxml_t target = ezxml_child(xmli, "target")) {
		MCONTACT hContInitiator = NULL;
		GCDEST gcd = { m_szModuleName, mChatID, 0};
		GCEVENT gce = { sizeof(gce), &gcd };
		gce.dwFlags = GCEF_ADDTOLOG;

		if (!mir_strcmp(xmli->name, "deletemember")) {
			gcd.iType = GC_EVENT_PART;
			if (ezxml_t initiator = ezxml_child(xmli, "initiator")) {
				if (mir_strcmp(initiator->txt, target->txt)) {
					hContInitiator = MSN_HContactFromEmail(initiator->txt);
					gce.ptszStatus = GetContactNameT(hContInitiator);
					gcd.iType = GC_EVENT_KICK;
				}
			}
		}
		else if (!mir_strcmp(xmli->name, "addmember")) {
			gcd.iType = GC_EVENT_JOIN;
		}
		else if (!mir_strcmp(xmli->name, "roleupdate")) {
			gcd.iType = GC_EVENT_ADDSTATUS;
			if (ezxml_t initiator = ezxml_child(xmli, "initiator")) {
				hContInitiator = MSN_HContactFromEmail(initiator->txt);
				gce.ptszText= GetContactNameT(hContInitiator);
			}
			gce.ptszStatus = _T("admin");
		}

		if (gcd.iType) {
			gce.time = MsnTSToUnixtime(ezxml_txt(ezxml_child(xmli, "eventtime")));
			const char *pszTarget = NULL;

			while (target) {
				switch (gcd.iType) {
				case GC_EVENT_JOIN:
					gce.ptszStatus = MSN_GCGetRole(MSN_GetThreadByChatId(mChatID), target->txt);
					// ..fall through.. //
				case GC_EVENT_KICK:
				case GC_EVENT_PART:
					pszTarget = target->txt;
					break;
				case GC_EVENT_ADDSTATUS:
				case GC_EVENT_REMOVESTATUS:
					gcd.iType = mir_strcmp(ezxml_txt(ezxml_child(target, "role")), "admin") == 0 ? GC_EVENT_ADDSTATUS : GC_EVENT_REMOVESTATUS;
					pszTarget = ezxml_txt(ezxml_child(target, "id"));
					break;
				}
				char *szEmail, *szNet;
				parseWLID(NEWSTR_ALLOCA(pszTarget), &szNet, &szEmail, NULL);
				gce.bIsMe = !mir_strcmpi(szEmail, GetMyUsername(atoi(szNet)));
				gce.ptszUID = mir_a2t(pszTarget);
				MCONTACT hContTarget = MSN_HContactFromEmail(pszTarget);
				gce.ptszNick = GetContactNameT(hContTarget);
				CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
				mir_free((TCHAR*)gce.ptszUID);
				if ((gcd.iType == GC_EVENT_PART || gcd.iType == GC_EVENT_KICK) && gce.bIsMe) {
					GCDEST gcd2 = { m_szModuleName, mChatID, GC_EVENT_CONTROL };
					GCEVENT gce2 = { sizeof(gce2), &gcd2 };
					CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce2);
					break;
				}
				target = ezxml_next(target);
			}
		}
	}
}
Exemple #22
0
bool CMsnProto::MSN_StoreUpdateProfile(const char* szNick, const char* szStatus, bool lock, bool allowRecurse)
{
    char* reqHdr;
    ezxml_t tbdy;
    ezxml_t xmlp = storeSoapHdr("UpdateProfile", "RoamingIdentityChanged", tbdy, reqHdr);

    ezxml_t pro = ezxml_add_child(tbdy, "profile", 0);
    ezxml_t node = ezxml_add_child(pro, "ResourceID", 0);
    ezxml_set_txt(node, proresid);

    ezxml_t expro = ezxml_add_child(pro, "ExpressionProfile", 0);
    node = ezxml_add_child(expro, "FreeText", 0);
    ezxml_set_txt(node, "Update");
    if (szNick)
    {
        node = ezxml_add_child(expro, "DisplayName", 0);
        ezxml_set_txt(node, szNick);
    }
    if (szStatus)
    {
        node = ezxml_add_child(expro, "PersonalStatus", 0);
        ezxml_set_txt(node, szStatus);
    }
    node = ezxml_add_child(expro, "Flags", 0);
    ezxml_set_txt(node, lock ? "1" : "0");

    char* szData = ezxml_toxml(xmlp, true);

    ezxml_free(xmlp);

    unsigned status = 0;
    char *storeUrl = NULL, *tResult = NULL;

    for (int k = 4; --k;)
    {
        mir_free(storeUrl);
        storeUrl = GetStoreHost("UpdateProfile");
        tResult = getSslResult(&storeUrl, szData, reqHdr, status);
        if (tResult == NULL) UpdateStoreHost("UpdateProfile", NULL);
        else break;
    }

    mir_free(reqHdr);
    free(szData);

    if (tResult != NULL)
    {
        UpdateStoreHost("UpdateProfile", storeUrl);
        if (status == 200)
        {
            replaceStr(msnLastStatusMsg, szStatus);
            MSN_ABUpdateDynamicItem();
        }
        else if (status == 500 && allowRecurse)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            const char* szErr = ezxml_txt(getSoapFault(xmlm, true));
            if (strcmp(szErr, "PassportAuthFail") == 0)
            {
                MSN_GetPassportAuth();
                status = MSN_StoreUpdateProfile(szNick, szStatus, lock, false) ? 200 : 500;
            }
            ezxml_free(xmlm);
        }
    }

    mir_free(tResult);
    mir_free(storeUrl);

    return status == 200;
}
Exemple #23
0
bool CMsnProto::MSN_StoreGetProfile(bool allowRecurse)
{
    char* reqHdr;
    ezxml_t tbdy;
    ezxml_t xmlp = storeSoapHdr("GetProfile", "Initial", tbdy, reqHdr);

    ezxml_t prohndl = ezxml_add_child(tbdy, "profileHandle", 0);

    ezxml_t alias = ezxml_add_child(prohndl, "Alias", 0);
    ezxml_t node = ezxml_add_child(alias, "Name", 0);
    ezxml_set_txt(node, mycid);
    node = ezxml_add_child(alias, "NameSpace", 0);
    ezxml_set_txt(node, "MyCidStuff");

    node = ezxml_add_child(prohndl, "RelationshipName", 0);
    ezxml_set_txt(node, "MyProfile");

    ezxml_t proattr = ezxml_add_child(tbdy, "profileAttributes", 0);
    node = ezxml_add_child(proattr, "ResourceID", 0);
    ezxml_set_txt(node, "true");
    node = ezxml_add_child(proattr, "DateModified", 0);
    ezxml_set_txt(node, "true");

    ezxml_t exproattr = ezxml_add_child(proattr, "ExpressionProfileAttributes", 0);
    node = ezxml_add_child(exproattr, "ResourceID", 0);
    ezxml_set_txt(node, "true");
    node = ezxml_add_child(exproattr, "DateModified", 0);
    ezxml_set_txt(node, "true");
    node = ezxml_add_child(exproattr, "DisplayName", 0);
    ezxml_set_txt(node, "true");
    node = ezxml_add_child(exproattr, "DisplayNameLastModified", 0);
    ezxml_set_txt(node, "true");
    node = ezxml_add_child(exproattr, "PersonalStatus", 0);
    ezxml_set_txt(node, "true");
    node = ezxml_add_child(exproattr, "PersonalStatusLastModified", 0);
    ezxml_set_txt(node, "true");
    node = ezxml_add_child(exproattr, "StaticUserTilePublicURL", 0);
    ezxml_set_txt(node, "true");
    node = ezxml_add_child(exproattr, "Photo", 0);
    ezxml_set_txt(node, "true");
    node = ezxml_add_child(exproattr, "Flags", 0);
    ezxml_set_txt(node, "true");

    char* szData = ezxml_toxml(xmlp, true);

    ezxml_free(xmlp);

    unsigned status = 0;
    char *storeUrl = NULL, *tResult = NULL;

    for (int k = 4; --k;)
    {
        mir_free(storeUrl);
        storeUrl = GetStoreHost("GetProfile");
        tResult = getSslResult(&storeUrl, szData, reqHdr, status);
        if (tResult == NULL) UpdateStoreHost("GetProfile", NULL);
        else break;
    }

    mir_free(reqHdr);
    free(szData);

    if (tResult != NULL)
    {
        if (status == 200)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            ezxml_t body = getSoapResponse(xmlm, "GetProfile");

            UpdateStoreHost("GetProfile", body ? storeUrl : NULL);

            mir_snprintf(proresid, sizeof(proresid), "%s", ezxml_txt(ezxml_child(body, "ResourceID")));

            ezxml_t expr = ezxml_child(body, "ExpressionProfile");
            if (expr == NULL)
            {
                MSN_StoreShareItem(proresid);
                MSN_SharingMyProfile();
                if (allowRecurse) MSN_StoreGetProfile(false);
            }
            else
            {
                const char* szNick = ezxml_txt(ezxml_child(expr, "DisplayName"));
                setStringUtf(NULL, "Nick", (char*)szNick);

                const char* szStatus = ezxml_txt(ezxml_child(expr, "PersonalStatus"));
                replaceStr(msnLastStatusMsg, szStatus);

                mir_snprintf(expresid, sizeof(expresid), "%s", ezxml_txt(ezxml_child(expr, "ResourceID")));

                ezxml_t photo = ezxml_child(expr, "Photo");
                mir_snprintf(photoid, sizeof(photoid), "%s", ezxml_txt(ezxml_child(photo, "ResourceID")));

                ezxml_t docstr = ezxml_get(photo, "DocumentStreams", 0, "DocumentStream", -1);
                while (docstr)
                {
                    const char *docname = ezxml_txt(ezxml_child(docstr, "DocumentStreamName"));
                    if (!strcmp(docname, "UserTileStatic"))
                    {
                        getMyAvatarFile(ezxml_txt(ezxml_child(docstr, "PreAuthURL")), _T("miranda_avatar.tmp"));
                        break;
                    }
                    docstr = ezxml_next(docstr);
                }
            }
            ezxml_free(xmlm);
        }
        else if (status == 500 && allowRecurse)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            const char* szErr = ezxml_txt(getSoapFault(xmlm, true));
            if (strcmp(szErr, "PassportAuthFail") == 0)
            {
                MSN_GetPassportAuth();
                MSN_StoreGetProfile(false);
            }
            else
            {
                MSN_StoreCreateProfile();
                if (MSN_StoreGetProfile(false)) status = 200;
            }
            ezxml_free(xmlm);
        }
        else
            UpdateStoreHost("GetProfile", NULL);

    }
    mir_free(tResult);
    mir_free(storeUrl);

    return status == 200;
}
Exemple #24
0
void CMsnProto::MSN_ChatStart(ezxml_t xmli)
{
	if (!mir_strcmp(xmli->txt, "thread"))
		return;

	// If Chat ID already exists, don'T create a new one
	const char *pszID = ezxml_txt(ezxml_child(xmli, "id"));
	GCThreadData* info = MSN_GetThreadByChatId(_A2T(pszID));
	if (info == NULL) {
		info = new GCThreadData;
		{
			mir_cslock lck(m_csThreads);
			m_arGCThreads.insert(info);
		}

		MSN_ChatInit(info, pszID, ezxml_txt(ezxml_get(xmli, "properties", 0, "topic", -1)));
		MSN_StartStopTyping(info, false);
	}
	else {
		GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_CONTROL };
		GCEVENT gce = { sizeof(gce), &gcd };
		CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce);
	}

	const char *pszCreator = ezxml_txt(ezxml_get(xmli, "properties", 0, "creator", -1));

	for (ezxml_t memb = ezxml_get(xmli, "members", 0, "member", -1); memb != NULL; memb = ezxml_next(memb)) {
		const char *mri = ezxml_txt(ezxml_child(memb, "mri"));
		const char *role = ezxml_txt(ezxml_child(memb, "role"));
		GCUserItem *gcu = NULL;

		for (int j = 0; j < info->mJoinedContacts.getCount(); j++) {
			if (!mir_strcmp(info->mJoinedContacts[j]->WLID, mri)) {
				gcu = info->mJoinedContacts[j];
				break;
			}
		}
		if (!gcu) {
			gcu = new GCUserItem;
			info->mJoinedContacts.insert(gcu);
			strncpy(gcu->WLID, mri, sizeof(gcu->WLID));
		}
		mir_tstrcpy(gcu->role, _A2T(role));

		if (pszCreator && !mir_strcmp(mri, pszCreator)) info->mCreator = gcu;
		char* szEmail, *szNet;
		parseWLID(NEWSTR_ALLOCA(mri), &szNet, &szEmail, NULL);
		if (!mir_strcmpi(szEmail, GetMyUsername(atoi(szNet))))
			info->mMe = gcu;
		gcu->btag = 1;
	}

	// Remove contacts not on list (not tagged)
	for (int j = 0; j < info->mJoinedContacts.getCount(); j++) {
		if (!info->mJoinedContacts[j]->btag) {
			info->mJoinedContacts.remove(j);
			j--;
		}
		else info->mJoinedContacts[j]->btag = 0;
	}
}
Exemple #25
0
bool CMsnProto::MSN_StoreDeleteRelationships(bool tile, bool allowRecurse)
{
    char* reqHdr;
    ezxml_t tbdy;
    ezxml_t xmlp = storeSoapHdr("DeleteRelationships", "RoamingIdentityChanged", tbdy, reqHdr);

    ezxml_t srch = ezxml_add_child(tbdy, "sourceHandle", 0);

    ezxml_t node;
    if (tile)
    {
        node = ezxml_add_child(srch, "RelationshipName", 0);
        ezxml_set_txt(node, "/UserTiles");

        ezxml_t alias = ezxml_add_child(srch, "Alias", 0);
        node = ezxml_add_child(alias, "Name", 0);
        ezxml_set_txt(node, mycid);
        node = ezxml_add_child(alias, "NameSpace", 0);
        ezxml_set_txt(node, "MyCidStuff");
    }
    else
    {
        node = ezxml_add_child(srch, "ResourceID", 0);
        ezxml_set_txt(node, expresid);
    }

    node = ezxml_add_child(tbdy, "targetHandles", 0);
    node = ezxml_add_child(node, "ObjectHandle", 0);
    node = ezxml_add_child(node, "ResourceID", 0);
    ezxml_set_txt(node, photoid);

    char* szData = ezxml_toxml(xmlp, true);

    ezxml_free(xmlp);

    unsigned status = 0;
    char *storeUrl = NULL, *tResult = NULL;

    for (int k = 4; --k;)
    {
        mir_free(storeUrl);
        storeUrl = GetStoreHost("DeleteRelationships");
        tResult = getSslResult(&storeUrl, szData, reqHdr, status);
        if (tResult == NULL) UpdateStoreHost("DeleteRelationships", NULL);
        else break;
    }

    mir_free(reqHdr);
    free(szData);

    if (tResult != NULL)
    {
        UpdateStoreHost("DeleteRelationships", storeUrl);
        if (status == 500)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            const char* szErr = ezxml_txt(getSoapFault(xmlm, true));
            if (strcmp(szErr, "PassportAuthFail") == 0 && allowRecurse)
            {
                MSN_GetPassportAuth();
                status = MSN_StoreDeleteRelationships(tile, false) ? 200 : 500;
            }
            ezxml_free(xmlm);
        }
    }

    mir_free(tResult);
    mir_free(storeUrl);

    return status == 200;
}
Exemple #26
0
/* Load geometric dimensions and description (if any) */
static SDError
SDloadGeometry(SDData *sd, ezxml_t wtl)
{
	ezxml_t		node, matl, geom;
	double		cfact;
	const char	*fmt = NULL, *mgfstr;

	SDerrorDetail[0] = '\0';
	sd->matn[0] = '\0'; sd->makr[0] = '\0';
	sd->dim[0] = sd->dim[1] = sd->dim[2] = 0;
	matl = ezxml_child(wtl, "Material");
	if (matl != NULL) {			/* get material info. */
		if ((node = ezxml_child(matl, "Name")) != NULL) {
			strncpy(sd->matn, ezxml_txt(node), SDnameLn);
			if (sd->matn[SDnameLn-1])
				strcpy(sd->matn+(SDnameLn-4), "...");
		}
		if ((node = ezxml_child(matl, "Manufacturer")) != NULL) {
			strncpy(sd->makr, ezxml_txt(node), SDnameLn);
			if (sd->makr[SDnameLn-1])
				strcpy(sd->makr+(SDnameLn-4), "...");
		}
		if ((node = ezxml_child(matl, "Width")) != NULL)
			sd->dim[0] = atof(ezxml_txt(node)) *
					to_meters(ezxml_attr(node, "unit"));
		if ((node = ezxml_child(matl, "Height")) != NULL)
			sd->dim[1] = atof(ezxml_txt(node)) *
					to_meters(ezxml_attr(node, "unit"));
		if ((node = ezxml_child(matl, "Thickness")) != NULL)
			sd->dim[2] = atof(ezxml_txt(node)) *
					to_meters(ezxml_attr(node, "unit"));
		if ((sd->dim[0] < 0) | (sd->dim[1] < 0) | (sd->dim[2] < 0)) {
			if (!SDerrorDetail[0])
				sprintf(SDerrorDetail, "Negative dimension in \"%s\"",
							sd->name);
			return SDEdata;
		}
	}
	sd->mgf = NULL;
	geom = ezxml_child(wtl, "Geometry");
	if (geom == NULL)			/* no actual geometry? */
		return SDEnone;
	fmt = ezxml_attr(geom, "format");
	if (fmt != NULL && strcasecmp(fmt, "MGF")) {
		sprintf(SDerrorDetail,
			"Unrecognized geometry format '%s' in \"%s\"",
					fmt, sd->name);
		return SDEsupport;
	}
	if ((node = ezxml_child(geom, "MGFblock")) == NULL ||
			(mgfstr = ezxml_txt(node)) == NULL)
		return SDEnone;
	while (isspace(*mgfstr))
		++mgfstr;
	if (!*mgfstr)
		return SDEnone;
	cfact = to_meters(ezxml_attr(node, "unit"));
	if (cfact <= 0)
		return SDEformat;
	sd->mgf = (char *)malloc(strlen(mgfstr)+32);
	if (sd->mgf == NULL) {
		strcpy(SDerrorDetail, "Out of memory in SDloadGeometry");
		return SDEmemory;
	}
	if (cfact < 0.99 || cfact > 1.01)
		sprintf(sd->mgf, "xf -s %.5f\n%s\nxf\n", cfact, mgfstr);
	else
		strcpy(sd->mgf, mgfstr);
	return SDEnone;
}
Exemple #27
0
bool CMsnProto::MSN_StoreCreateDocument(const TCHAR *sztName, const char *szMimeType, const char *szPicData, bool allowRecurse)
{
    char* reqHdr;
    ezxml_t tbdy;
    char* szName = mir_utf8encodeT(sztName);
    ezxml_t xmlp = storeSoapHdr("CreateDocument", "RoamingIdentityChanged", tbdy, reqHdr);

    ezxml_t hndl = ezxml_add_child(tbdy, "parentHandle", 0);
    ezxml_t node = ezxml_add_child(hndl, "RelationshipName", 0);
    ezxml_set_txt(node, "/UserTiles");

    ezxml_t alias = ezxml_add_child(hndl, "Alias", 0);
    node = ezxml_add_child(alias, "Name", 0);
    ezxml_set_txt(node, mycid);
    node = ezxml_add_child(alias, "NameSpace", 0);
    ezxml_set_txt(node, "MyCidStuff");

    ezxml_t doc = ezxml_add_child(tbdy, "document", 0);
    ezxml_set_attr(doc, "xsi:type", "Photo");
    node = ezxml_add_child(doc, "Name", 0);
    ezxml_set_txt(node, szName);

    doc = ezxml_add_child(doc, "DocumentStreams", 0);
    doc = ezxml_add_child(doc, "DocumentStream", 0);
    ezxml_set_attr(doc, "xsi:type", "PhotoStream");
    node = ezxml_add_child(doc, "DocumentStreamType", 0);

    ezxml_set_txt(node, "UserTileStatic");
    node = ezxml_add_child(doc, "MimeType", 0);
    ezxml_set_txt(node, szMimeType);
    node = ezxml_add_child(doc, "Data", 0);
    ezxml_set_txt(node, szPicData);
    node = ezxml_add_child(doc, "DataSize", 0);
    ezxml_set_txt(node, "0");

    node = ezxml_add_child(tbdy, "relationshipName", 0);
    ezxml_set_txt(node, "Messenger User Tile");

    char* szData = ezxml_toxml(xmlp, true);

    ezxml_free(xmlp);
    mir_free(szName);

    unsigned status = 0;
    char *storeUrl = NULL, *tResult = NULL;

    for (int k = 4; --k;)
    {
        mir_free(storeUrl);
        storeUrl = GetStoreHost("CreateDocument");
        tResult = getSslResult(&storeUrl, szData, reqHdr, status);
        if (tResult == NULL) UpdateStoreHost("CreateDocument", NULL);
        else break;
    }

    mir_free(reqHdr);
    free(szData);

    if (tResult != NULL)
    {
        UpdateStoreHost("CreateDocument", storeUrl);
        if (status == 200)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            ezxml_t bdy = getSoapResponse(xmlm, "CreateDocument");
            mir_snprintf(photoid, sizeof(photoid), "%s", ezxml_txt(bdy));
            ezxml_free(xmlm);
        }
        else if (status == 500)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            const char* szErr = ezxml_txt(getSoapFault(xmlm, true));
            if (strcmp(szErr, "PassportAuthFail") == 0 && allowRecurse)
            {
                MSN_GetPassportAuth();
                status = MSN_StoreCreateDocument(sztName, szMimeType, szPicData, false) ? 200 : 500;
            }
            ezxml_free(xmlm);
        }
    }

    mir_free(tResult);
    mir_free(storeUrl);

    return status == 200;
}