void lin_refresh(void) { GtkTreeStore *treestore; GtkTreeIter toplevel, child; remove_all(); treestore = GTK_TREE_STORE(gtk_tree_view_get_model( GTK_TREE_VIEW(view))); gchar *p = NULL; gchar *q = NULL; struct sockaddr_in addr; int i,j; GList *group = NULL; GList *user = NULL; LinpopUser *temp ; char buf[256]; gboolean result; //userListForeach(printUser,NULL); for(group = getGroupList();group != NULL;group = group->next){ p = (gchar *)group->data; gtk_tree_store_append(treestore, &toplevel, NULL); gtk_tree_store_set(treestore, &toplevel,COLUMN, p,-1); g_print("group:%s\n",p); for(user = getGroupUserList(p);user != NULL;user = user->next){ /* q = (gchar *)user->data; gtk_tree_store_append(treestore, &child, &toplevel); gtk_tree_store_set(treestore, &child,COLUMN,q,-1); g_print("user:%s\n",q);*/ bzero(buf,sizeof(buf)); q = (gchar *)user->data; temp = g_malloc(sizeof(*temp)); inet_aton(q,&addr.sin_addr); result = getUserByIP(addr,temp); assert(result == TRUE); strcat(buf,temp->user); strcat(buf,"("); strcat(buf,q); strcat(buf,")"); strcpy(q,buf); g_print("q is:%s\n",q); gtk_tree_store_append(treestore, &child, &toplevel); gtk_tree_store_set(treestore, &child,COLUMN,q,-1); g_print("user:%s\n",q); freeUser(temp); } } return GTK_TREE_MODEL(treestore); }
//----------------------------------------------------------------------------- // Group::getGroupWithAttribute //----------------------------------------------------------------------------- cdma::IGroupPtr Group::getGroupWithAttribute(const std::string& name, const std::string& value) { IGroupPtr result = NULL; std::list<cdma::IGroupPtr> groups = getGroupList(); for( std::list<cdma::IGroupPtr>::iterator iter = groups.begin(); iter != groups.end(); iter++ ) { if( (*iter)->hasAttribute(name) ) { IAttributePtr attr = (*iter)->getAttribute(name); if( attr->getValue<std::string>() == value ) { result = *iter; break; } } } return result; }
bool GenExchangeTestService::getGroupListTS(const uint32_t &token, std::list<RsGxsGroupId> &groupIds) { return getGroupList(token, groupIds); }
void listRefresh(void) { GtkTreeStore *treestore; GtkTreeIter toplevel, child; remove_all(); treestore = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(view))); gchar *p = NULL; gchar *q = NULL; struct sockaddr_in addr; int i,j; GList *group = NULL; GList *user = NULL; LinpopUser *temp ; char buf[256]; gboolean result; //userListForeach(printUser,NULL); //我的好友列表建立 p="特别好友"; gtk_tree_store_append(treestore, &toplevel, NULL); gtk_tree_store_set(treestore, &toplevel,COLUMN, p,-1); for(user = getGroupUserList(p);user != NULL;user = user->next){ bzero(buf,sizeof(buf)); q = (gchar *)user->data; temp = g_malloc(sizeof(*temp)); inet_aton(q,&addr.sin_addr); result = getUserByIP(addr,temp); assert(result == TRUE); strcat(buf,temp->user); strcat(buf,"("); strcat(buf,q); strcat(buf,")"); strcpy(q,buf); g_print("q is special:%s\n",q); gtk_tree_store_append(treestore, &child, &toplevel); gtk_tree_store_set(treestore, &child,COLUMN,q,-1); g_print("user special :%s\n",q); freeUser(temp); } //gtk_tree_store_append(treestore, &child, &toplevel); //q=NULL; //gtk_tree_store_set(treestore, &child,COLUMN,q,-1); //!!!!!!!!!!!! for(group = getGroupList();group != NULL;group = group->next){ p = (gchar *)group->data; if((strcmp(p,"黑名单")== 0) || (strcmp(p,"特别好友")== 0)){ continue; g_print("ignore\n"); } gtk_tree_store_append(treestore, &toplevel, NULL); gtk_tree_store_set(treestore, &toplevel,COLUMN, p,-1); g_print("n group:%s\n",p); for(user = getGroupUserList(p);user != NULL;user = user->next){ bzero(buf,sizeof(buf)); q = (gchar *)user->data; temp = g_malloc(sizeof(*temp)); inet_aton(q,&addr.sin_addr); result = getUserByIP(addr,temp); assert(result == TRUE); strcat(buf,temp->user); strcat(buf,"("); strcat(buf,q); strcat(buf,")"); strcpy(q,buf); g_print("n q is:%s\n",q); gtk_tree_store_append(treestore, &child, &toplevel); gtk_tree_store_set(treestore, &child,COLUMN,q,-1); g_print("n user:%s\n",q); freeUser(temp); } } //黑名单列表建立 p="黑名单"; gtk_tree_store_append(treestore, &toplevel, NULL); gtk_tree_store_set(treestore, &toplevel,COLUMN, p,-1); for(user = getGroupUserList(p);user != NULL;user = user->next){ bzero(buf,sizeof(buf)); q = (gchar *)user->data; temp = g_malloc(sizeof(*temp)); inet_aton(q,&addr.sin_addr); result = getUserByIP(addr,temp); assert(result == TRUE); strcat(buf,temp->user); strcat(buf,"("); strcat(buf,q); strcat(buf,")"); strcpy(q,buf); g_print("b q is:%s\n",q); gtk_tree_store_append(treestore, &child, &toplevel); gtk_tree_store_set(treestore, &child,COLUMN,q,-1); g_print("b user:%s\n",q); g_print("diff\n"); freeUser(temp); } // gtk_tree_store_append(treestore, &child, &toplevel); //q=NULL; //gtk_tree_store_set(treestore, &child,COLUMN,q,-1); //!!!!!!!!!!!! numToStr(buf,getUserNumber()); strcat(buf," friends online"); gtk_entry_set_text (GTK_ENTRY (entry), buf); /*for(i = 0,p = g_list_nth_data(group,i); p != NULL ;i++){ gtk_tree_store_append(treestore, &toplevel, NULL); gtk_tree_store_set(treestore, &toplevel,COLUMN, p,-1); g_print("p:%s\n",p); user = getGroupUserList(p); for(j = 0,q = g_list_nth_data(user,j); q != NULL;j++ ){ gtk_tree_store_append(treestore, &child, &toplevel); gtk_tree_store_set(treestore, &child,COLUMN,q,-1); g_print("q:%s\n",q); } }*/ }
ProductRule *JsonParser::getProductRuleFromText(QString text){ int majorVersion = -1; int minorVersion = -1; QString product = ""; QList<QString> *groupList = NULL; QMap<QString, QList<QString> > *groupRegexMap = NULL; QMap<QString, QList<QString> > *groupHighlightMap = NULL; QList<QString> *layerList = NULL; QMap<QString, QList<QString> > *layerMap = NULL; bool success = false; QString failReason = ""; do{ // convert qstring to json object QJsonObject root = QJsonDocument::fromJson(text.toUtf8()).object(); if(root.count() == 0){ failReason = QString("json syntax might be wrong."); break; } // root level if(!root.contains(KEY_MAJOR_VERSION)) { failReason = QString("KEY %1 doesn't exist on root level.").arg(KEY_MAJOR_VERSION); break; } bool majorOK; majorVersion = root.value(KEY_MAJOR_VERSION).toString().toInt(&majorOK); if(!majorOK){ failReason = "major version isn't Integer value"; break; } if(!root.contains(KEY_MINOR_VERSION)){ failReason = QString("KEY %1 doesn't exist on root level.").arg(KEY_MINOR_VERSION); break; } bool minorOK; minorVersion = root.value(KEY_MINOR_VERSION).toString().toInt(&minorOK); if(!minorOK){ failReason = "minor version isn't Integer value"; break; } if(!root.contains(KEY_PRODUCT)) { failReason = QString("KEY %1 doesn't exist on root level.").arg(KEY_PRODUCT); break; } product = root.value(KEY_PRODUCT).toString(); // group if(!root.contains(KEY_GROUP)) { failReason = QString("KEY %1 doesn't exist on root level.").arg(KEY_GROUP); break; } QJsonArray groupArray = root.value(KEY_GROUP).toArray(); groupList = getGroupList(groupArray); if(groupList == NULL){ failReason = "Iteration fail on getGroupList()"; break; } groupRegexMap = getGroupRegexMap(groupArray); if(groupRegexMap == NULL){ failReason = "Iteration fail on getGroupRegexMap()"; break; } groupHighlightMap = getGroupHighlightMap(groupArray); if(groupHighlightMap == NULL){ failReason = "Iteration fail on getGroupHighlightMap()"; break; } // layer if(!root.contains(KEY_LAYER)) { failReason = QString("KEY %1 doesn't exist on root level.").arg(KEY_LAYER); break; } QJsonArray layerArray = root.value(KEY_LAYER).toArray(); layerList = getLayerList(layerArray); if(layerList == NULL){ failReason = "Iteration fail on getLayerList()"; break; } layerMap = getLayerMap(layerArray); if(layerMap == NULL){ failReason = "Iteration fail on getLayerMap()"; break; } // all OK. success = true; }while(false); if(success){ return new ProductRule(majorVersion, minorVersion, product, groupList, groupRegexMap, groupHighlightMap, layerList, layerMap); }else{ qDebug() << failReason; return NULL; } }
void getInvariants(char *db, struct snpExceptions *exceptionList, struct slName *chromList, char *fileBase) /* write list of invariants to output file */ { struct sqlConnection *conn = hAllocConn(db); struct sqlResult *sr = NULL; struct snpExceptions *el = NULL; struct slName *chrom = NULL; char **row = NULL; char query[1024]; unsigned long int invariantCount; char thisFile[64]; FILE *outFile; int colCount, i; char idString[3]; for (el=exceptionList; el!=NULL; el=el->next) { if (el->exceptionId<10) safef(idString,sizeof(idString), "0%d", el->exceptionId); else safef(idString,sizeof(idString), "%d", el->exceptionId); invariantCount = 0; if (startsWith("select",el->query)) { safef(thisFile, sizeof(thisFile), "%s.%s.bed", fileBase, idString); outFile = mustOpen(thisFile, "w"); fprintf(outFile, "# exceptionId:\t%d\n# query:\t%s;\n", el->exceptionId, el->query); for (chrom=chromList; chrom!=NULL; chrom=chrom->next) { fflush(outFile); /* to keep an eye on output progress */ sqlSafef(query, sizeof(query), "%-s and chrom='%s'", el->query, chrom->name); sr = sqlGetResult(conn, query); colCount = sqlCountColumns(sr); while ((row = sqlNextRow(sr))!=NULL) { invariantCount++; fprintf(outFile, "%s", row[0]); for (i=1; i<colCount; i++) fprintf(outFile, "\t%s", row[i]); fprintf(outFile, "\n"); } } } else if (startsWith("group",el->query)) { struct slName *nameList = NULL; struct slName *name = NULL; safef(thisFile, sizeof(thisFile), "%s.%s.bed", fileBase, idString); outFile = mustOpen(thisFile, "w"); fprintf(outFile, "# exceptionId:\t%d\n# query:\t%s;\n", el->exceptionId, el->query); nameList = getGroupList(db, el->query); for (name=nameList; name!=NULL; name=name->next) { sqlSafef(query, sizeof(query), "select chrom,chromStart,chromEnd,name,%d as score,class,locType,observed " "from snp where name='%s'", el->exceptionId, name->name); sr = sqlGetResult(conn, query); colCount = sqlCountColumns(sr); while ((row = sqlNextRow(sr))!=NULL) { invariantCount++; fprintf(outFile, "%s", row[0]); for (i=1; i<colCount; i++) fprintf(outFile, "\t%s", row[i]); fprintf(outFile, "\n"); } } } else { printf("Invariant %d has no query string\n", el->exceptionId); continue; } carefulClose(&outFile); printf("Invariant %d has %lu exceptions, written to this file: %s\n", el->exceptionId, invariantCount, thisFile); fflush(stdout); sqlSafef(query, sizeof(query), "update snpExceptions set num=%lu where exceptionId=%d", invariantCount, el->exceptionId); sr=sqlGetResult(conn, query); /* there's probably a better way to do this */ } }