Example #1
0
void RLBlock::SetShape()
{
    this->SetSize(this->x(),this->y(),200,200);
    this->InitBlocksList();
    QBitArray newstatus(16);
    newstatus.setBit(0,true);
    newstatus.setBit(1,true);
    newstatus.setBit(4,true);
    newstatus.setBit(8,true);
    this->addStatus(newstatus);

    QBitArray newstatus1(16);
    newstatus1.setBit(0,true);
    newstatus1.setBit(4,true);
    newstatus1.setBit(5,true);
    newstatus1.setBit(6,true);
    this->addStatus(newstatus1);

    QBitArray newstatus2(16);
    newstatus2.setBit(1,true);
    newstatus2.setBit(5,true);
    newstatus2.setBit(8,true);
    newstatus2.setBit(9,true);
    this->addStatus(newstatus2);

    QBitArray newstatus3(16);
    newstatus3.setBit(0,true);
    newstatus3.setBit(1,true);
    newstatus3.setBit(2,true);
    newstatus3.setBit(6,true);
    this->addStatus(newstatus3);
}
Example #2
0
void IBlock::SetShape()
{
    this->SetSize(this->x(),this->y(),200,200);
    this->InitBlocksList();
    QBitArray newstatus(16);
    newstatus.setBit(0,true);
    newstatus.setBit(1,true);
    newstatus.setBit(2,true);
    newstatus.setBit(3,true);
    this->addStatus(newstatus);

    QBitArray newstatus1(16);
    newstatus1.setBit(0,true);
    newstatus1.setBit(4,true);
    newstatus1.setBit(8,true);
    newstatus1.setBit(12,true);
    this->addStatus(newstatus1);
}
Example #3
0
int parse_status(xmlDocPtr *doc, xmlNode *node, status **stptr){
    if(!node || !doc || !stptr)
        return -1;
    xmlNode *attr = node->children;

    status *st = *stptr;
    while(attr){ // parse status attributes
        if(!xmlStrcmp(attr->name, (const xmlChar *)"id")){ //status id
            char *id = xmlNodeListGetString(*doc, attr->xmlChildrenNode, 1);
            if(id){
                // look up status by id
                /*
                pthread_mutex_lock(&status_map_mutex);
                st = g_hash_table_lookup(status_map,id);
                pthread_mutex_unlock(&status_map_mutex);
                */
                if(!st){
                    // create new status and insert into the map
                    st = newstatus();
                    st->id = strdup(id);
                    /*
                    pthread_mutex_lock(&status_map_mutex);
                    g_hash_table_insert(status_map,st->id,st);
                    pthread_mutex_unlock(&status_map_mutex);
                    */
                }
                else
                    break;
            }
            else
                break;
        }
        else if(!xmlStrcmp(attr->name, (const xmlChar *)"text")){ //status text
            char *text = xmlNodeListGetString(*doc, attr->xmlChildrenNode, 1);
            if(text){
                st->wtext = malloc((TWEET_MAX_LEN+1)*sizeof(wchar_t));
                memset(st->wtext,'\0',(TWEET_MAX_LEN+1)*sizeof(wchar_t));
                st->length = mbstowcs(st->wtext,text,TWEET_MAX_LEN);
            }
        }
        else if(!xmlStrcmp(attr->name, (const xmlChar *)"favorited")){ 
            char *favorited = xmlNodeListGetString(*doc, attr->xmlChildrenNode, 1);
            if(favorited && strcmp(favorited,"true") == 0)
                SET_FAVORITED(st->extra_info);
        }
        else if(!xmlStrcmp(attr->name, (const xmlChar *)"user")){ //user
            parse_user(doc,attr,&(st->composer));
        }
        /*
        else if(!xmlStrcmp(attr->name, (const xmlChar *)"in_reply_to_status_id")){ 
            char *in_reply_to_status_id = xmlNodeListGetString(*doc, attr->xmlChildrenNode, 1);
            if(in_reply_to_status_id && strlen(in_reply_to_status_id) > 0){
                st->in_reply_to_status_id = strdup(in_reply_to_status_id);
            }
        }
        */
        else if(!xmlStrcmp(attr->name,(const xmlChar *)"retweeted_status")){
            parse_status(doc,attr,&(st->retweeted_status));
            /*
            for(entity *et=st->retweeted_status->entities;et;et=et->next)
                printf("%ls\n",et->text);
                */
        }
        else if(!xmlStrcmp(attr->name,(const xmlChar *)"entities")){
            parse_entities(doc,attr,st);
        }
        attr = attr->next;
    }
    split_status_entities(st);
    *stptr = st;
    return 0;
}
Example #4
0
int parse_status_json(json_t *status_root, status **status_ptr){
    json_t *idstr = json_object_get(status_root, "id_str");
    if(!json_is_string(idstr))
        return -1;
    json_t *textstr = json_object_get(status_root, "text");
    if(!json_is_string(textstr))
        return -1;

    status *st = newstatus();
    st->id = strdup(json_string_value(idstr));
    //json_decref(idstr);
    const char *text = json_string_value(textstr);
    st->wtext = malloc(sizeof(wchar_t)*(TWEET_MAX_LEN+1));
    mbstowcs(st->wtext, text, TWEET_MAX_LEN+1);
    //json_decref(textstr);
    st->length = wcslen(st->wtext);
    parse_user_json(json_object_get(status_root, "user"),&(st->composer));

    //printf("\n@%s --  %ls\n", st->composer->screen_name, st->wtext);

    json_t *entities = json_object_get(status_root, "entities");
    if(!entities)
        return -1;

    entity *prev = NULL;
    for(int i = 0; i < ENTITY_TYPE_COUNT; i++){
        json_t *entities_array = json_object_get(entities,entities_keys[i]);
        if(json_is_array(entities_array) && json_array_size(entities_array) > 0){
            for(int j = 0; j < json_array_size(entities_array); ++j){
                json_t *entity_root = json_array_get(entities_array, j);
                if(!entity_root)
                    continue;

                entity *et = newentity();
                et->type = entity_types[i];
                if(parse_entity_json(entity_root,et,st) < 0)
                    destroy_entity(et);
                else{
                    st->entity_count ++;
                    if(!(st->entities))
                        st->entities = et;
                    else
                        prev->next = et;
                    prev = et;
                }
            }
        }
    }

    split_status_entities(st);
    
    json_t *retweeted_status_root = json_object_get(status_root,"retweeted_status");
    if(retweeted_status_root){ 
        int result = parse_status_json(retweeted_status_root,&(st->retweeted_status));
        if(result == -1)
            st->retweeted_status = NULL;
    }
    /*
    for(entity *et = st->entities;et;et=et->next)
        printf("%ls ",et->text);
    printf("\n");
    */

    *status_ptr = st;

    return 0;
}