void send_ignore_modifiers(fmodule *module) { char msg[64]; sprintf(msg, "IgnoreModifiers %d\n", GetUnusedModifiers()); SendName(module, M_CONFIG_INFO, 0, 0, 0, msg); return; }
static void send_move_threshold(fmodule *module) { char msg[64]; sprintf(msg, "MoveThreshold %d\n", Scr.MoveThreshold); SendName(module, M_CONFIG_INFO, 0, 0, 0, msg); return; }
static void send_color_limit(fmodule *module) { #ifndef DISABLE_COLORLIMIT_CONFIG_INFO char msg[64]; sprintf(msg, "ColorLimit %d\n", Scr.ColorLimit); SendName(module, M_CONFIG_INFO, 0, 0, 0, msg); #endif return; }
static void send_desktop_geometry(fmodule *module) { char msg[64]; sprintf(msg, "DesktopSize %d %d\n", Scr.VxMax / Scr.MyDisplayWidth + 1, Scr.VyMax / Scr.MyDisplayHeight + 1); SendName(module, M_CONFIG_INFO, 0, 0, 0, msg); return; }
static void send_desktop_geometry(fmodule *module) { char msg[64]; struct monitor *m = monitor_get_current(); sprintf(msg, "DesktopSize %d %d\n", m->virtual_scr.VxMax / m->coord.w + 1, m->virtual_scr.VyMax / m->coord.h + 1); SendName(module, M_CONFIG_INFO, 0, 0, 0, msg); return; }
static void send_click_time(fmodule *module) { char msg[64]; /* Dominik Vogt (8-Nov-1998): Scr.ClickTime patch to set ClickTime to * 'not at all' during InitFunction and RestartFunction. */ sprintf(msg,"ClickTime %d\n", (Scr.ClickTime < 0) ? -Scr.ClickTime : Scr.ClickTime); SendName(module, M_CONFIG_INFO, 0, 0, 0, msg); return; }
static void send_colorsets(fmodule *module) { int n; /* dump the colorsets (0 first as others copy it) */ for (n = 0; n < nColorsets; n++) { SendName( module, M_CONFIG_INFO, 0, 0, 0, DumpColorset(n, &Colorset[n])); } return; }
static void send_image_path(fmodule *module) { char *msg; char *ImagePath = PictureGetImagePath(); if (ImagePath && *ImagePath != 0) { msg = safemalloc(strlen(ImagePath) + 12); sprintf(msg, "ImagePath %s\n", ImagePath); SendName(module, M_CONFIG_INFO, 0, 0, 0, msg); free(msg); } return; }
static void send_desktop_names(fmodule *module) { DesktopsInfo *d; char *name; for (d = Scr.Desktops->next; d != NULL; d = d->next) { if (d->name != NULL) { name = (char *)safemalloc(strlen(d->name) + 44); sprintf(name,"DesktopName %d %s", d->desk, d->name); SendName(module, M_CONFIG_INFO, 0, 0, 0, name); free(name); } } return; }
/* * send an arbitrary string to all instances of a module */ void SendStrToModule(XEvent * eventp, Window junk, FvwmWindow * tmp_win, unsigned long context, char *action, int *Module) { char *module, *str; int i; GetNextToken(action, &module); str = strdup(action + strlen(module) + 1); for (i = 0; i < npipes; i++) { if ((pipeName[i] != NULL) && (matchWildcards(module, pipeName[i]))) { SendName(i, M_STRING, 0, 0, 0, str); } } free(module); free(str); }
static void SendConfigToModule( fmodule *module, const struct moduleInfoList *entry, char *match, int match_len) { if (match) { if (match_len == 0) { match_len = strlen(match); } if (entry->alias_len > 0 && entry->alias_len != match_len) { return; } /* migo: this should be strncmp not strncasecmp probably. */ if (strncasecmp(entry->data, match, match_len) != 0) { return; } } SendName(module, M_CONFIG_INFO, 0, 0, 0, entry->data); return; }
static void send_desktop_names(fmodule *module) { struct monitor *m = monitor_get_current(); DesktopsInfo *d; char *name; /* TA: Currently, the names of desktops are the same for each monitor, * so pick the current monitor and send those names. */ for (d = m->Desktops->next; d != NULL; d = d->next) { if (d->name != NULL) { /* TA: FIXME! xasprintf() */ name = mvwm_malloc(strlen(d->name) + 44); sprintf(name,"DesktopName %d %s", d->desk, d->name); SendName(module, M_CONFIG_INFO, 0, 0, 0, name); free(name); } } return; }
static void send_xinerama_state(fmodule *module) { SendName(module, M_CONFIG_INFO, 0, 0, 0, FScreenGetConfiguration()); return; }
void send_list_func(XEvent * eventp, Window w, FvwmWindow * tmp_win, unsigned long context, char *action, int *Module) { FvwmWindow *t; if (*Module >= 0) { SendPacket(*Module, M_NEW_DESK, 1, Scr.CurrentDesk, 0, 0, 0, 0, 0, 0); SendPacket(*Module, M_NEW_PAGE, 5, Scr.Vx, Scr.Vy, Scr.CurrentDesk, Scr.VxMax, Scr.VyMax, 0, 0); if (Scr.Hilite != NULL) SendPacket(*Module, M_FOCUS_CHANGE, 5, Scr.Hilite->w, Scr.Hilite->frame, (unsigned long) Scr.Hilite, Scr.ActiveTitleColors.fore, Scr.ActiveTitleColors.back, 0, 0); else SendPacket(*Module, M_FOCUS_CHANGE, 5, 0, 0, 0, Scr.ActiveTitleColors.fore, Scr.ActiveTitleColors.back, 0, 0); if (Scr.DefaultIcon != NULL) SendName(*Module, M_DEFAULTICON, 0, 0, 0, Scr.DefaultIcon); for (t = Scr.FvwmRoot.next; t != NULL; t = t->next) { SendConfig(*Module, M_CONFIGURE_WINDOW, t); SendName(*Module, M_WINDOW_NAME, t->w, t->frame, (unsigned long) t, t->name); SendName(*Module, M_ICON_NAME, t->w, t->frame, (unsigned long) t, t->icon_name); if (t->icon_bitmap_file != NULL && t->icon_bitmap_file != Scr.DefaultIcon) SendName(*Module, M_ICON_FILE, t->w, t->frame, (unsigned long) t, t->icon_bitmap_file); SendName(*Module, M_RES_CLASS, t->w, t->frame, (unsigned long) t, t->class.res_class); SendName(*Module, M_RES_NAME, t->w, t->frame, (unsigned long) t, t->class.res_name); if ((t->flags & ICONIFIED) && (!(t->flags & ICON_UNMAPPED))) SendPacket(*Module, M_ICONIFY, 7, t->w, t->frame, (unsigned long) t, t->icon_x_loc, t->icon_y_loc, t->icon_w_width, t->icon_w_height + t->icon_p_height); if ((t->flags & ICONIFIED) && (t->flags & ICON_UNMAPPED)) SendPacket(*Module, M_ICONIFY, 7, t->w, t->frame, (unsigned long) t, 0, 0, 0, 0); if (t->title_icon != NULL) SendPacket(*Module, M_MINI_ICON, 6, t->w, /* Watch Out ! : I reduced the set of infos... */ t->title_icon->picture, t->title_icon->mask, t->title_icon->width, t->title_icon->height, t->title_icon->depth, 0); } if (Scr.Hilite == NULL) { Broadcast(M_FOCUS_CHANGE, 5, 0, 0, 0, Scr.ActiveTitleColors.fore, Scr.ActiveTitleColors.back, 0, 0); } else { Broadcast(M_FOCUS_CHANGE, 5, Scr.Hilite->w, Scr.Hilite->frame, (unsigned long) Scr.Hilite, Scr.ActiveTitleColors.fore, Scr.ActiveTitleColors.back, 0, 0); } SendPacket(*Module, M_END_WINDOWLIST, 0, 0, 0, 0, 0, 0, 0, 0); }
void netClient::Go() { mapClientTile tile; // for use in map updates netMapTile tileData; netMapEntity entityData; netMapUpdateBBox bbox; netMapReset mapReset; netGroupData groupData; netClientLocation clientLoc; hnPoint point; sint8 levelCount; netInventory inven; netInventoryItem item; objDescription *objList; uint16 objectID; objType objectType; m_display->TextMessage("Trying to connect to server...\n"); if ( connect( m_socket, (sockaddr *)m_serverAddress, sizeof(sockaddr) ) == -1 ) { perror("connect"); cleanexit(1); } m_display->TextMessage("Connected!\n"); // Now that we're connected, send the server our name. SendName( m_display->GetName() ); // now that we've connected, we wait for packets from the server or a key from our hnClient... m_display->Go(); while(!m_done){ // do stuff here until we quit. short readSizeBytesLeft = sizeof(sint16); short incomingBytes; char * incomingBuffer = (char *)&incomingBytes; // Emulate functionality of MSG_WAITALL, 'cause some architectures don't support it. while ( readSizeBytesLeft > 0 ) { #ifdef __DEBUGGING_NETWORK__ printf("Waiting for %d bytes of packet size data..\n", readSizeBytesLeft); #endif int bytesRead = recv( m_socket, incomingBuffer, readSizeBytesLeft, 0 ); #ifdef __DEBUGGING_NETWORK__ printf("Received %d bytes.\n",bytesRead); #endif if ( bytesRead == -1 ) { perror("recv"); cleanexit(1); } incomingBuffer += bytesRead; readSizeBytesLeft -= bytesRead; } incomingBytes = ntohs(incomingBytes); int remainingBytes = incomingBytes; //printf("Receiving %d bytes...\n", incomingBytes); char buffer[incomingBytes]; char *bufferPointer = buffer; // Emulate functionality of MSG_WAITALL, 'cause some architectures don't support it. while ( remainingBytes > 0 ) { #ifdef __DEBUGGING_NETWORK__ printf("Waiting for %d bytes of packet data..\n", remainingBytes ); #endif int bytesRead = recv( m_socket, bufferPointer, remainingBytes, 0 ); #ifdef __DEBUGGING_NETWORK__ printf("Received %d bytes.\n", bytesRead); #endif if ( bytesRead == -1 ) { perror("recv"); cleanexit(1); } bufferPointer += bytesRead; remainingBytes -= bytesRead; } #ifdef __DISPLAY_PACKET_CONTENT__ printf("Packet of %d bytes:\n", incomingBytes ); char *bufferstart = buffer; for ( int i = 0; i < incomingBytes; i++ ) { printf("Value: %d\n",*(bufferstart + i)); } printf("\n"); #endif netMetaPacketInput *packet = new netMetaPacketInput(buffer, incomingBytes); while ( !packet->Done() ) { sint8 type = packet->PeekSint8(); #define MAX_MESSAGE_BYTES (256) char messageBuffer[MAX_MESSAGE_BYTES]; sint16 messageBufferLength = MAX_MESSAGE_BYTES; switch ( type ) { case SPT_ClientLocation: packet->ClientLocation(clientLoc); m_display->UpdateLocation( clientLoc.loc ); break; case SPT_GroupData: packet->GroupData(groupData); m_display->UpdateGroupData(groupData.memberCount, groupData.memberTurns, groupData.haveTurnFromClient ); break; case SPT_ClientStatistics: case SPT_ClientHitPoints: case SPT_ClientSpellPoints: case SPT_ClientExperience: m_display->GetStatus()->ReceiveChanges( packet ); break; case SPT_MapTile: packet->MapTile(tileData); if ( m_display->isMapReady( tileData.loc.z ) ) { tile.material = (hnMaterialType)tileData.material; tile.wall = (hnWallType)tileData.wall; m_display->UpdateMapTile(tileData.loc, tile); } break; case SPT_Message: packet->TextMessage(messageBuffer, messageBufferLength); m_display->TextMessage(messageBuffer); break; case SPT_ObjectStats: packet->ObjectStats(objectID); m_display->SetObjectStats(objectID); break; case SPT_ObjectName: packet->ObjectName(objectID, objectType, messageBuffer, messageBufferLength); m_display->SetObjectName(objectID, objectType, messageBuffer); break; case SPT_MapEntity: packet->MapEntity(entityData); if ( m_display->isMapReady( bbox.loc.z ) ) m_display->UpdateMapCreature(entityData.loc, entityData.objectType); break; case SPT_DungeonReset: packet->DungeonReset(levelCount); m_display->DungeonReset(levelCount); case SPT_MapReset: packet->MapReset(mapReset); m_display->MapReset(mapReset.width, mapReset.height, mapReset.depth); break; case SPT_MapUpdateBBox: packet->MapUpdateBBox(bbox); // If we haven't prepared this map yet, ask for a full refresh of // this map, so we can initialise our map structures. if ( !m_display->isMapReady( bbox.loc.z ) ) { SendRefreshRequest( bbox.loc.z ); break; } for ( int i = 0; i < bbox.width; i++ ) for ( int j = 0; j < bbox.height; j++ ) { tile.material = bbox.material[i+(j*bbox.width)]; tile.wall = bbox.wall[i+(j*bbox.width)]; point.Set(bbox.loc.x+i, bbox.loc.y+j, 0); tile.entity = bbox.entityType[i+(j*bbox.width)]; tile.objectCount = bbox.objectCount[i+(j*bbox.width)]; tile.object = new objDescription[tile.objectCount]; for ( int k = 0; k < tile.objectCount; k++ ) tile.object[k] = bbox.object[i+(j*bbox.width)][k]; m_display->UpdateMapTile( hnPoint(bbox.loc.x+i, bbox.loc.y+j, bbox.loc.z), tile); delete [] tile.object; } break; case SPT_Inventory: packet->Inventory(inven); objList = new objDescription[inven.GetObjectCount()]; for ( int i = 0; i < inven.GetObjectCount(); i++ ) objList[i] = inven.GetObject(i); m_display->UpdateInventory(inven.GetObjectCount(), objList); delete [] objList; break; case SPT_InventoryItem: packet->InventoryItem(item); m_display->UpdateInventoryItem(item.object, item.inventorySlot); break; case SPT_TakenItem: packet->TakenItem(item); m_display->TakenItem(item.object, item.inventorySlot); break; case SPT_DroppedItem: packet->DroppedItem(item); m_display->DroppedItem(item.object); break; case SPT_WieldedItem: packet->WieldedItem(item); m_display->WieldedItem(item.object, item.inventorySlot); break; case SPT_BadPacketNotice: packet->BadPacketNotice(); delete m_display; printf("Server killed us for sending an unknown packet. Version mismatch?\n"); m_done = true; //exit(1); break; case SPT_QuitConfirm: packet->QuitConfirm(); m_done = true; break; default: printf("Unknown packet type %d!! :(\n", type); break; } } m_display->Refresh(); // do a screen refresh if we need it. } close( m_socket ); }