From 275bbb751736a849fcda6da0e8b6d1ab3eee06d4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Fri, 28 Aug 2009 21:13:28 +0000 Subject: [PATCH] * move marchlist into its own file * remove spaces from makefile; s.b. complained about this * change the new iconbar room treeview from dynamic to static structures; this saves computing power and makes sorting / filtering much cheaper than having to search through a list for structure members. * move room related stuff to its own header. * cache floors in the session, thoy don't change in such a high frequency. --- webcit/config.guess | 107 +++++------ webcit/config.sub | 67 +++++-- webcit/marchlist.c | 2 +- webcit/messages.c | 1 - webcit/po/Makefile.in | 4 +- webcit/roomops.c | 302 +++++++++++++++++++++----------- webcit/roomops.h | 81 +++++++++ webcit/static/t/json_floor.html | 2 +- webcit/static/t/json_room.html | 2 +- webcit/subst.h | 2 +- webcit/webcit.h | 47 +---- 11 files changed, 400 insertions(+), 217 deletions(-) create mode 100644 webcit/roomops.h diff --git a/webcit/config.guess b/webcit/config.guess index f32079abd..e3a2116a7 100755 --- a/webcit/config.guess +++ b/webcit/config.guess @@ -1,10 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 # Free Software Foundation, Inc. -timestamp='2008-01-23' +timestamp='2009-06-10' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -170,7 +170,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null + | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? @@ -324,6 +324,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; @@ -331,7 +334,20 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize @@ -640,7 +656,7 @@ EOF # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep __LP64__ >/dev/null + grep -q __LP64__ then HP_ARCH="hppa2.0w" else @@ -796,7 +812,7 @@ EOF x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; - EM64T | authenticamd) + EM64T | authenticamd | genuineintel) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) @@ -806,6 +822,9 @@ EOF [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we @@ -866,40 +885,17 @@ EOF m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; - mips:Linux:*:*) + mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU - #undef mips - #undef mipsel + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel + CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips - #else - CPU= - #endif - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^CPU/{ - s: ::g - p - }'`" - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips64 - #undef mips64el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mips64el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips64 + CPU=${UNAME_MACHINE} #else CPU= #endif @@ -931,10 +927,13 @@ EOF EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-gnu + exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in @@ -982,17 +981,6 @@ EOF elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build @@ -1058,7 +1046,7 @@ EOF i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) @@ -1102,8 +1090,11 @@ EOF pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 @@ -1141,6 +1132,16 @@ EOF 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; @@ -1153,7 +1154,7 @@ EOF rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) @@ -1216,6 +1217,9 @@ EOF BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; @@ -1324,6 +1328,9 @@ EOF i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 diff --git a/webcit/config.sub b/webcit/config.sub index 6759825a5..eb0389a69 100755 --- a/webcit/config.sub +++ b/webcit/config.sub @@ -1,10 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 # Free Software Foundation, Inc. -timestamp='2008-01-16' +timestamp='2009-06-11' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -122,6 +122,7 @@ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` @@ -152,6 +153,9 @@ case $os in os= basic_machine=$1 ;; + -bluegene*) + os=-cnk + ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 @@ -249,13 +253,16 @@ case $basic_machine in | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ + | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore | mep \ + | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ - | mips64vr | mips64vrel \ + | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ @@ -268,6 +275,7 @@ case $basic_machine in | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ + | moxie \ | mt \ | msp430 \ | nios | nios2 \ @@ -277,7 +285,7 @@ case $basic_machine in | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | score \ - | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ @@ -286,7 +294,7 @@ case $basic_machine in | v850 | v850e \ | we32k \ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ - | z8k) + | z8k | z80) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) @@ -329,14 +337,17 @@ case $basic_machine in | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ + | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ - | mips64vr-* | mips64vrel-* \ + | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ @@ -358,20 +369,20 @@ case $basic_machine in | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ - | z8k-*) + | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) @@ -439,6 +450,10 @@ case $basic_machine in basic_machine=m68k-apollo os=-bsd ;; + aros) + basic_machine=i386-pc + os=-aros + ;; aux) basic_machine=m68k-apple os=-aux @@ -455,10 +470,18 @@ case $basic_machine in basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; c90) basic_machine=c90-cray os=-unicos ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; convex-c1) basic_machine=c1-convex os=-bsd @@ -526,6 +549,10 @@ case $basic_machine in basic_machine=m88k-motorola os=-sysv3 ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp @@ -1128,6 +1155,10 @@ case $basic_machine in basic_machine=z8k-unknown os=-sim ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; none) basic_machine=none-none os=-none @@ -1166,7 +1197,7 @@ case $basic_machine in we32k) basic_machine=we32k-att ;; - sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) @@ -1236,10 +1267,11 @@ case $os in # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ + | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ @@ -1248,7 +1280,7 @@ case $os in | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ + | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ @@ -1388,6 +1420,9 @@ case $os in -zvmoe) os=-zvmoe ;; + -dicos*) + os=-dicos + ;; -none) ;; *) @@ -1585,7 +1620,7 @@ case $basic_machine in -sunos*) vendor=sun ;; - -aix*) + -cnk*|-aix*) vendor=ibm ;; -beos*) diff --git a/webcit/marchlist.c b/webcit/marchlist.c index 8838cd351..736b498a6 100644 --- a/webcit/marchlist.c +++ b/webcit/marchlist.c @@ -1,6 +1,6 @@ #include "webcit.h" #include "webserver.h" - +#include "roomops.h" /* * Free a session's march list diff --git a/webcit/messages.c b/webcit/messages.c index 921f5366d..b123b8c5a 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -1687,7 +1687,6 @@ void RegisterReadLoopHandlerset( Handler->ViewCleanup = ViewCleanup; Put(ReadLoopHandler, IKEY(RoomType), Handler, NULL); - } void diff --git a/webcit/po/Makefile.in b/webcit/po/Makefile.in index d699313f9..2f98a3743 100644 --- a/webcit/po/Makefile.in +++ b/webcit/po/Makefile.in @@ -46,6 +46,6 @@ all: ../locale/de/LC_MESSAGES/webcit.mo \ msgfmt hu.po -o ../locale/hu/LC_MESSAGES/webcit.mo ../locale/et_EE/LC_MESSAGES/webcit.mo: et_EE.po - [ -d ../locale/et_EE/LC_MESSAGES ] || mkdir -p ../locale/et_EE/LC_MESSAGES - msgfmt et_EE.po -o ../locale/et_EE/LC_MESSAGES/webcit.mo + [ -d ../locale/et_EE/LC_MESSAGES ] || mkdir -p ../locale/et_EE/LC_MESSAGES + msgfmt et_EE.po -o ../locale/et_EE/LC_MESSAGES/webcit.mo diff --git a/webcit/roomops.c b/webcit/roomops.c index 6b668f6f7..2018ab431 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -5,6 +5,7 @@ #include "webcit.h" #include "webserver.h" +#include "roomops.h" #define MAX_FLOORS 128 char floorlist[MAX_FLOORS][SIZ]; /* list of our floor names */ @@ -15,22 +16,6 @@ char *viewdefs[9]; /* the different kinds of available views */ * Basically we pull LFLR/LKRA etc. and set up a room HashList with these keys. */ -#define FLOOR_PARAM_LEN 3 -const ConstStr FLOOR_PARAM_NAMES[] = {{HKEY("ID")}, - {HKEY("NAME")}, - {HKEY("ROOMS")}}; - -#define ROOM_PARAM_LEN 8 -const ConstStr ROOM_PARAM_NAMES[] = {{HKEY("NAME")}, - {HKEY("FLAG")}, - {HKEY("FLOOR")}, - {HKEY("LISTORDER")}, - {HKEY("ACL")}, - {HKEY("CURVIEW")}, - {HKEY("DEFVIEW")}, - {HKEY("LASTCHANGE")}}; - - void display_whok(void); /* @@ -2894,7 +2879,7 @@ void change_view(void) { * \param max_folders how many folders??? * \param num_floors hom many floors??? */ -void do_folder_view(struct folder *fold, int max_folders, int num_floors) { +void do_folder_view(struct __ofolder *fold, int max_folders, int num_floors) { char buf[SIZ]; int levels; int i; @@ -3013,7 +2998,7 @@ void do_folder_view(struct folder *fold, int max_folders, int num_floors) { * \param max_folders how many folders??? * \param num_floors hom many floors??? */ -void do_rooms_view(struct folder *fold, int max_folders, int num_floors) { +void do_rooms_view(struct __ofolder *fold, int max_folders, int num_floors) { char buf[256]; char floor_name[256]; char old_floor_name[256]; @@ -3134,7 +3119,7 @@ void set_floordiv_expanded(void) { * \param max_folders how many folders??? * \param num_floors hom many floors??? */ -void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) { +void do_iconbar_view(struct __ofolder *fold, int max_folders, int num_floors) { char buf[256]; char floor_name[256]; char old_floor_name[256]; @@ -3274,8 +3259,8 @@ void list_all_rooms_by_floor(const char *viewpref) { StrBuf *Buf; char buf[SIZ]; int swap = 0; - struct folder *fold = NULL; - struct folder ftmp; + struct __ofolder *fold = NULL; + struct __ofolder ftmp; int max_folders = 0; int alloc_folders = 0; int *floor_mapping; @@ -3303,8 +3288,8 @@ void list_all_rooms_by_floor(const char *viewpref) { /** Start with the mailboxes */ max_folders = 1; alloc_folders = 1; - fold = malloc(sizeof(struct folder)); - memset(fold, 0, sizeof(struct folder)); + fold = malloc(sizeof(struct __ofolder)); + memset(fold, 0, sizeof(struct __ofolder)); strcpy(fold[0].name, "My folders"); fold[0].is_mailbox = 1; @@ -3315,9 +3300,9 @@ void list_all_rooms_by_floor(const char *viewpref) { if (max_folders >= alloc_folders) { alloc_folders = max_folders + 100; fold = realloc(fold, - alloc_folders * sizeof(struct folder)); + alloc_folders * sizeof(struct __ofolder)); } - memset(&fold[max_folders], 0, sizeof(struct folder)); + memset(&fold[max_folders], 0, sizeof(struct __ofolder)); extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name); extract_token(buf3, buf, 0, '|', SIZ); fold[max_folders].floor = atol (buf3); @@ -3343,9 +3328,9 @@ void list_all_rooms_by_floor(const char *viewpref) { if (max_folders >= alloc_folders) { alloc_folders = max_folders + 100; fold = realloc(fold, - alloc_folders * sizeof(struct folder)); + alloc_folders * sizeof(struct __ofolder)); } - memset(&fold[max_folders], 0, sizeof(struct folder)); + memset(&fold[max_folders], 0, sizeof(struct __ofolder)); extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room); ra_flags = extract_int(buf, 5); flags = extract_int(buf, 1); @@ -3382,7 +3367,7 @@ void list_all_rooms_by_floor(const char *viewpref) { { if (fold[i].num_rooms == 0) { for (j=i; j 0) { - memcpy(&ftmp, &fold[j], sizeof(struct folder)); + memcpy(&ftmp, &fold[j], sizeof(struct __ofolder)); memcpy(&fold[j], &fold[j+1], - sizeof(struct folder)); + sizeof(struct __ofolder)); memcpy(&fold[j+1], &ftmp, - sizeof(struct folder)); + sizeof(struct __ofolder)); } } } @@ -3553,110 +3538,214 @@ void set_room_policy(void) { display_editroom(); } +void DeleteFloor(void *vFloor) +{ + floor *Floor; + Floor = (floor*) vFloor; + FreeStrBuf(&Floor->Name); + free(Floor); +} + HashList *GetFloorListHash(StrBuf *Target, WCTemplputParams *TP) { - /* todo: check context */ const char *Err; StrBuf *Buf; - StrBuf *Buf2; HashList *floors; - HashList *floor; - floors = NewHash(1, NULL); + floor *Floor; + const char *Pos; + wcsession *WCC = WC; + + if (WCC->Floors != NULL) + return WCC->Floors; + WCC->Floors = floors = NewHash(1, NULL); Buf = NewStrBuf(); serv_puts("LFLR"); /* get floors */ StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err); /* '100', we hope */ if (GetServerStatus(Buf, NULL) == 1) - while(StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err), strcmp(ChrPtr(Buf), "000")) { - int a; - const StrBuf *floorNum = NULL; - floor = NewHash(1, NULL); - for(a=0; aserv_sock, 0, &Err), strcmp(ChrPtr(Buf), "000")) + { + + Pos = NULL; + + Floor = malloc(sizeof(floor)); + Floor->ID = StrBufExtractNext_long(Buf, &Pos, '|'); + Floor->Name = NewStrBufPlain(NULL, StrLength(Buf)); + StrBufExtract_NextToken(Floor->Name, Buf, &Pos, '|'); + Floor->NRooms = StrBufExtractNext_long(Buf, &Pos, '|'); + + Put(floors, IKEY(Floor->ID), Floor, DeleteFloor); } + } FreeStrBuf(&Buf); return floors; } -void tmplput_FLOOR_Value(StrBuf *TemplBuffer, WCTemplputParams *TP) +void tmplput_FLOOR_ID(StrBuf *Target, WCTemplputParams *TP) +{ + floor *Floor = (floor *)(TP->Context); + + StrBufAppendPrintf(Target, "%d", Floor->ID); +} + +void tmplput_FLOOR_NAME(StrBuf *Target, WCTemplputParams *TP) +{ + floor *Floor = (floor *)(TP->Context); + + StrBufAppendTemplate(Target, TP, Floor->Name, 0); +} + +void tmplput_FLOOR_NROOMS(StrBuf *Target, WCTemplputParams *TP) { - StrBuf *val; - HashList *floor = (HashList *)(TP->Context); - void *value; - GetHash(floor, TKEY(0), &value); - val = (StrBuf *)value; - StrECMAEscAppend(TemplBuffer, val, 0); + floor *Floor = (floor *)(TP->Context); + + StrBufAppendPrintf(Target, "%d", Floor->NRooms); } HashList *GetRoomListHashLKRA(StrBuf *Target, WCTemplputParams *TP) { serv_puts("LKRA"); return GetRoomListHash(Target, TP); } + +void DeleteFolder(void *vFolder) +{ + folder *room; + room = (folder*) vFolder; + + FreeStrBuf(&room->name); + FreeStrBuf(&room->ACL); + + //// FreeStrBuf(&room->room); + + free(room); +} + + HashList *GetRoomListHash(StrBuf *Target, WCTemplputParams *TP) { /* TODO: Check context */ HashList *rooms; - HashList *room; - StrBuf *buf; - StrBuf *buf2; + folder *room; + StrBuf *Buf; + wcsession *WCC = WC; + const char *Pos; const char *Err; - buf = NewStrBuf(); + void *vFloor; + + Buf = NewStrBuf(); rooms = NewHash(1, NULL); - StrBufTCP_read_line(buf, &WC->serv_sock, 0, &Err); - if (GetServerStatus(buf, NULL) == 1) - while(StrBufTCP_read_line(buf, &WC->serv_sock, 0, &Err), strcmp(ChrPtr(buf), "000")) { - int i; - StrBuf *rmName = NULL; - room = NewHash(1, NULL); - for(i=0; iserv_sock, 0, &Err); + if (GetServerStatus(Buf, NULL) == 1) + { + while(StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err), + strcmp(ChrPtr(Buf), "000")) + { + + Pos = NULL; + room = (folder*) malloc (sizeof(folder)); + memset(room, 0, sizeof(folder)); + + room->name = NewStrBufPlain(NULL, StrLength(Buf)); + StrBufExtract_NextToken(room->name, Buf, &Pos, '|'); + + room->QRFlags = StrBufExtractNext_long(Buf, &Pos, '|'); + room->floorid = StrBufExtractNext_long(Buf, &Pos, '|'); + + room->listorder = StrBufExtractNext_long(Buf, &Pos, '|'); + + room->ACL = NewStrBufPlain(NULL, StrLength(Buf)); + StrBufExtract_NextToken(room->ACL, Buf, &Pos, '|'); + + room->view = StrBufExtractNext_long(Buf, &Pos, '|'); + room->defview = StrBufExtractNext_long(Buf, &Pos, '|'); + room->lastchange = StrBufExtractNext_long(Buf, &Pos, '|'); + + + GetHash(WCC->Floors, IKEY(room->floorid), &vFloor); + room->Floor = (const floor*) vFloor; + Put(rooms, SKEY(room->name), room, DeleteFolder); } + } SortByHashKey(rooms, 1); /*SortByPayload(rooms, SortRoomsByListOrder); */ - FreeStrBuf(&buf); + FreeStrBuf(&Buf); return rooms; } + /** Unused function that orders rooms by the listorder flag */ int SortRoomsByListOrder(const void *room1, const void *room2) { - int l1; - int l2; - HashList *r1 = (HashList *)GetSearchPayload(room1); - HashList *r2 = (HashList *)GetSearchPayload(room2); - StrBuf *listOrderBuf1; - StrBuf *listOrderBuf2; + folder *r1 = (folder*) room1; + folder *r2 = (folder*) room2; + + if (r1->listorder == r2->listorder) return 0; + if (r1->listorder > r2->listorder) return 1; + return -1; +} + +int SortRoomsByFloorAndName(const void *room1, const void *room2) +{ + folder *r1 = (folder*) room1; + folder *r2 = (folder*) room2; - GetHash(r1, CKEY(ROOM_PARAM_NAMES[3]), (void *)&listOrderBuf1); - GetHash(r2, CKEY(ROOM_PARAM_NAMES[3]), (void *)&listOrderBuf2); - l1 = atoi(ChrPtr(listOrderBuf1)); - l2 = atoi(ChrPtr(listOrderBuf2)); - if (l1 < l2) return -1; - else if (l1 > l2) return +1; - else return 0; + if (r1->Floor != r2->Floor) + return strcmp(ChrPtr(r1->Floor->Name), + ChrPtr(r2->Floor->Name)); + return strcmp (ChrPtr(r1->name), + ChrPtr(r2->name)); +} + + + +void tmplput_ROOM_NAME(StrBuf *Target, WCTemplputParams *TP) +{ + folder *Folder = (folder *)(TP->Context); + + StrBufAppendTemplate(Target, TP, Folder->name, 0); +} + +void tmplput_ROOM_ACL(StrBuf *Target, WCTemplputParams *TP) +{ + folder *Folder = (folder *)(TP->Context); + + StrBufAppendTemplate(Target, TP, Folder->ACL, 0); } -void tmplput_ROOM_Value(StrBuf *TemplBuffer, WCTemplputParams *TP) + + +void tmplput_ROOM_QRFLAGS(StrBuf *Target, WCTemplputParams *TP) { - void *value; - StrBuf *val; - HashList *room = (HashList *)(TP->Context); + folder *Folder = (folder *)(TP->Context); + StrBufAppendPrintf(Target, "%d", Folder->QRFlags); +} + + - GetHash(room, TKEY(0), &value); - val = (StrBuf *)value; - StrECMAEscAppend(TemplBuffer, val, 0); +void tmplput_ROOM_FLOORID(StrBuf *Target, WCTemplputParams *TP) +{ + folder *Folder = (folder *)(TP->Context); + StrBufAppendPrintf(Target, "%d", Folder->floorid); +} + +void tmplput_ROOM_LISTORDER(StrBuf *Target, WCTemplputParams *TP) +{ + folder *Folder = (folder *)(TP->Context); + StrBufAppendPrintf(Target, "%d", Folder->listorder); +} +void tmplput_ROOM_VIEW(StrBuf *Target, WCTemplputParams *TP) +{ + folder *Folder = (folder *)(TP->Context); + StrBufAppendPrintf(Target, "%d", Folder->view); +} +void tmplput_ROOM_DEFVIEW(StrBuf *Target, WCTemplputParams *TP) +{ + folder *Folder = (folder *)(TP->Context); + StrBufAppendPrintf(Target, "%d", Folder->defview); } +void tmplput_ROOM_LASTCHANGE(StrBuf *Target, WCTemplputParams *TP) +{ + folder *Folder = (folder *)(TP->Context); + StrBufAppendPrintf(Target, "%d", Folder->lastchange); +} + void jsonRoomFlr(void) { /* Send as our own (application/json) content type */ @@ -3939,10 +4028,24 @@ InitModule_ROOMOPS RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE); RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, 0); - RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, DeleteHash, CTX_FLOORS, CTX_NONE, IT_NOFLAG); - RegisterNamespace("FLOOR:INFO", 1, 2, tmplput_FLOOR_Value, CTX_FLOORS); + RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_NOFLAG); + + RegisterNamespace("FLOOR:ID", 0, 0, tmplput_FLOOR_ID, CTX_FLOORS); + RegisterNamespace("FLOOR:NAME", 0, 1, tmplput_FLOOR_NAME, CTX_FLOORS); + RegisterNamespace("FLOOR:NROOMS", 0, 0, tmplput_FLOOR_NROOMS, CTX_FLOORS); + + + RegisterIterator("LKRA", 0, NULL, GetRoomListHashLKRA, NULL, DeleteHash, CTX_ROOMS, CTX_NONE, IT_NOFLAG); - RegisterNamespace("ROOM:INFO", 1, 2, tmplput_ROOM_Value, CTX_ROOMS); + + RegisterNamespace("ROOM:INFO:FLOORID", 0, 1, tmplput_ROOM_FLOORID, CTX_ROOMS); + RegisterNamespace("ROOM:INFO:NAME", 0, 1, tmplput_ROOM_NAME, CTX_ROOMS); + RegisterNamespace("ROOM:INFO:ACL", 0, 1, tmplput_ROOM_ACL, CTX_ROOMS); + RegisterNamespace("ROOM:INFO:QRFLAGS", 0, 1, tmplput_ROOM_QRFLAGS, CTX_ROOMS); + RegisterNamespace("ROOM:INFO:LISTORDER", 0, 1, tmplput_ROOM_LISTORDER, CTX_ROOMS); + RegisterNamespace("ROOM:INFO:VIEW", 0, 1, tmplput_ROOM_VIEW, CTX_ROOMS); + RegisterNamespace("ROOM:INFO:DEFVIEW", 0, 1, tmplput_ROOM_DEFVIEW, CTX_ROOMS); + RegisterNamespace("ROOM:INFO:LASTCHANGE", 0, 1, tmplput_ROOM_LASTCHANGE, CTX_ROOMS); } @@ -3956,5 +4059,6 @@ SessionDestroyModule_ROOMOPS } free_march_list(sess); + DeleteHash(&sess->Floors); } /*@}*/ diff --git a/webcit/roomops.h b/webcit/roomops.h new file mode 100644 index 000000000..f31b66451 --- /dev/null +++ b/webcit/roomops.h @@ -0,0 +1,81 @@ + +/* + * \brief This struct holds a list of rooms for \\\oto operations. + */ +struct march { + struct march *next; /* pointer to next in linked list */ + char march_name[128]; /* name of room */ + int march_floor; /* floor number of room */ + int march_order; /* sequence in which we are to visit this room */ +}; + +/* * + * \brief This struct holds a list of rooms for client display. + * It is a binary tree. + */ +struct roomlisting { + struct roomlisting *lnext; /* pointer to 'left' tree node */ + struct roomlisting *rnext; /* pointer to 'right' tree node */ + char rlname[128]; /* name of room */ + unsigned rlflags; /* room flags */ + int rlfloor; /* the floor it resides on */ + int rlorder; /* room listing order */ +}; + + + + + +typedef struct _floor { + long ID; + StrBuf *Name; + long NRooms; +} floor; + +/** + * \brief Data structure for roomlist-to-folderlist conversion + */ +struct __ofolder { + int floor; /* which floor is it on */ + char room[SIZ]; /* which roomname ??? */ + char name[SIZ]; /* which is its own name??? */ + int hasnewmsgs; /* are there unread messages inside */ + int is_mailbox; /* is it a mailbox? */ + int selectable; /* can we select it ??? */ + int view; /* whats its default view? inbox/calendar.... */ + int num_rooms; /* If this is a floor, how many rooms does it have */ +}; + + + +/** + * \brief Data structure for roomlist-to-folderlist conversion + */ +typedef struct _folder { + StrBuf *name; /* which is its own name??? */ + int QRFlags; /* roomflags */ + int floorid; /* which floor is it on */ + + + int listorder; /* todo */ + + StrBuf *ACL; /* access Control list... */ + + int view; /* whats its default view? inbox/calendar.... */ + int defview; + int lastchange; /* todo... */ + + + + + const floor *Floor; /* pint to the floor we're on.. */ + StrBuf *room; /* which roomname ??? */ + + + int hasnewmsgs; /* are there unread messages inside */ + int is_mailbox; /* is it a mailbox? */ + int selectable; /* can we select it ??? */ + int num_rooms; /* If this is a floor, how many rooms does it have */ + +}folder; + diff --git a/webcit/static/t/json_floor.html b/webcit/static/t/json_floor.html index 50d9853eb..13838af94 100644 --- a/webcit/static/t/json_floor.html +++ b/webcit/static/t/json_floor.html @@ -1 +1 @@ -[, "", ] , +[, "", ] diff --git a/webcit/static/t/json_room.html b/webcit/static/t/json_room.html index 4ac6ff3ba..4e770f7c5 100644 --- a/webcit/static/t/json_room.html +++ b/webcit/static/t/json_room.html @@ -1 +1 @@ -["", , , ,, , , ] , +["", , , ,, , , ] diff --git a/webcit/subst.h b/webcit/subst.h index fec6d9589..a8741ad2a 100644 --- a/webcit/subst.h +++ b/webcit/subst.h @@ -1,4 +1,4 @@ -\ + extern HashList *Conditionals; extern HashList *GlobalNS; extern HashList *Iterators; diff --git a/webcit/webcit.h b/webcit/webcit.h index ad0ce0284..188c034d6 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -269,50 +269,6 @@ typedef struct _serv_info { } ServInfo; - -/* - * \brief This struct holds a list of rooms for \\\oto operations. - */ -struct march { - struct march *next; /* pointer to next in linked list */ - char march_name[128]; /* name of room */ - int march_floor; /* floor number of room */ - int march_order; /* sequence in which we are to visit this room */ -}; - -/* * - * \brief This struct holds a list of rooms for client display. - * It is a binary tree. - */ -struct roomlisting { - struct roomlisting *lnext; /* pointer to 'left' tree node */ - struct roomlisting *rnext; /* pointer to 'right' tree node */ - char rlname[128]; /* name of room */ - unsigned rlflags; /* room flags */ - int rlfloor; /* the floor it resides on */ - int rlorder; /* room listing order */ -}; - - - - - - - -/** - * \brief Data structure for roomlist-to-folderlist conversion - */ -struct folder { - int floor; /* which floor is it on */ - char room[SIZ]; /* which roomname ??? */ - char name[SIZ]; /* which is its own name??? */ - int hasnewmsgs; /* are there unread messages inside */ - int is_mailbox; /* is it a mailbox? */ - int selectable; /* can we select it ??? */ - int view; /* whats its default view? inbox/calendar.... */ - int num_rooms; /* If this is a floor, how many rooms does it have */ -}; - typedef struct _disp_cal { icalcomponent *cal; /* cal items for display */ long cal_msgnum; /* cal msgids for display */ @@ -535,6 +491,7 @@ struct wcsession { int remember_new_mail; /**< last count of new mail messages */ /* Roomiew control */ + HashList *Floors; /**< floors our citserver has... */ HashList *summ; /**< list of messages for mailbox summary view */ /** Perhaps these should be within a struct instead */ long startmsg; /**< message number to start at */ @@ -546,7 +503,7 @@ struct wcsession { char last_chat_user[256]; /**< ??? todo */ /* Iconbar controls */ - struct folder *cache_fold; /**< cache the iconbar room list */ + struct __ofolder *cache_fold; /**< cache the iconbar room list */ int cache_max_folders; /**< ??? todo */ int cache_num_floors; /**< ??? todo */ time_t cache_timestamp; /**< ??? todo */ -- 2.30.2