paul@800 | 1 | #!/bin/sh |
paul@800 | 2 | |
paul@1024 | 3 | . "`dirname \"$0\"`/common.sh" |
paul@800 | 4 | |
paul@800 | 5 | USER="mailto:vincent.vole@example.com" |
paul@800 | 6 | SENDER="mailto:paul.boddie@example.com" |
paul@800 | 7 | FBFILE="$STORE/$USER/freebusy" |
paul@800 | 8 | FBOFFERFILE="$STORE/$USER/freebusy-offers" |
paul@800 | 9 | FBSENDERFILE="$STORE/$SENDER/freebusy" |
paul@800 | 10 | FBSENDEROTHERFILE="$STORE/$SENDER/freebusy-other/$USER" |
paul@800 | 11 | FBSENDERREQUESTS="$STORE/$SENDER/requests" |
paul@800 | 12 | |
paul@800 | 13 | mkdir -p "$PREFS/$USER" |
paul@800 | 14 | echo 'Europe/Oslo' > "$PREFS/$USER/TZID" |
paul@800 | 15 | echo 'share' > "$PREFS/$USER/freebusy_sharing" |
paul@800 | 16 | echo 'PT60S' > "$PREFS/$USER/freebusy_offers" |
paul@800 | 17 | |
paul@800 | 18 | "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person-all.txt" 2>> $ERROR \ |
paul@800 | 19 | | "$SHOWMAIL" \ |
paul@800 | 20 | > out0.tmp |
paul@800 | 21 | |
paul@800 | 22 | grep -q 'METHOD:REPLY' out0.tmp \ |
paul@800 | 23 | && ! grep -q '^FREEBUSY' out0.tmp \ |
paul@800 | 24 | && echo "Success" \ |
paul@800 | 25 | || echo "Failed" |
paul@800 | 26 | |
paul@800 | 27 | # Attempt to schedule an event. |
paul@800 | 28 | |
paul@800 | 29 | "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person.txt" 2>> $ERROR |
paul@800 | 30 | |
paul@800 | 31 | grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE" \ |
paul@800 | 32 | && echo "Success" \ |
paul@800 | 33 | || echo "Failed" |
paul@800 | 34 | |
paul@800 | 35 | # Present the request to the recipient. |
paul@800 | 36 | |
paul@800 | 37 | "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-request-person.txt" 2>> $ERROR \ |
paul@800 | 38 | | "$SHOWMAIL" \ |
paul@800 | 39 | > out1.tmp |
paul@800 | 40 | |
paul@800 | 41 | ! grep -q 'METHOD:REPLY' out1.tmp \ |
paul@800 | 42 | && echo "Success" \ |
paul@800 | 43 | || echo "Failed" |
paul@800 | 44 | |
paul@800 | 45 | ! [ -e "$FBFILE" ] \ |
paul@800 | 46 | || ! grep -q "event6@example.com" "$FBFILE" \ |
paul@800 | 47 | && echo "Success" \ |
paul@800 | 48 | || echo "Failed" |
paul@800 | 49 | |
paul@800 | 50 | ! [ -e "$FBOTHERFILE" ] \ |
paul@800 | 51 | || ! grep -q "event6@example.com" "$FBOTHERFILE" \ |
paul@800 | 52 | && echo "Success" \ |
paul@800 | 53 | || echo "Failed" |
paul@800 | 54 | |
paul@800 | 55 | # Counter the invitation. |
paul@800 | 56 | |
paul@800 | 57 | "$COUNTER_SCRIPT" $COUNTER_ARGS "$USER" 20141126T170000 20141126T180000 "event6@example.com" 2>> $ERROR \ |
paul@800 | 58 | | tee out2r.tmp \ |
paul@800 | 59 | | "$SHOWMAIL" \ |
paul@800 | 60 | > out2.tmp |
paul@800 | 61 | |
paul@800 | 62 | # Note that the invitation has only been prepared, not processed. |
paul@800 | 63 | |
paul@800 | 64 | ! [ -e "$FBFILE" ] \ |
paul@800 | 65 | || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \ |
paul@800 | 66 | && ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBFILE" ) \ |
paul@800 | 67 | && echo "Success" \ |
paul@800 | 68 | || echo "Failed" |
paul@800 | 69 | |
paul@800 | 70 | grep -q 'METHOD:COUNTER' out2.tmp \ |
paul@800 | 71 | && grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T170000' out2.tmp \ |
paul@800 | 72 | && echo "Success" \ |
paul@800 | 73 | || echo "Failed" |
paul@800 | 74 | |
paul@800 | 75 | ! [ -e "$FBOFFERFILE" ] \ |
paul@800 | 76 | || ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBOFFERFILE" \ |
paul@800 | 77 | && echo "Success" \ |
paul@800 | 78 | || echo "Failed" |
paul@800 | 79 | |
paul@800 | 80 | # Send the counter-proposal. |
paul@800 | 81 | |
paul@800 | 82 | "$OUTGOING_SCRIPT" $ARGS < out2r.tmp 2>> $ERROR |
paul@800 | 83 | |
paul@800 | 84 | ! [ -e "$FBFILE" ] \ |
paul@800 | 85 | || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \ |
paul@800 | 86 | && ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBFILE" ) \ |
paul@800 | 87 | && echo "Success" \ |
paul@800 | 88 | || echo "Failed" |
paul@800 | 89 | |
paul@800 | 90 | grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBOFFERFILE" \ |
paul@800 | 91 | && echo "Success" \ |
paul@800 | 92 | || echo "Failed" |
paul@804 | 93 | |
paul@804 | 94 | # Present the response to the organiser. |
paul@804 | 95 | |
paul@804 | 96 | "$PERSON_SCRIPT" $ARGS < out2r.tmp 2>> $ERROR \ |
paul@804 | 97 | | tee out3r.tmp \ |
paul@804 | 98 | | "$SHOWMAIL" \ |
paul@804 | 99 | > out3.tmp |
paul@804 | 100 | |
paul@804 | 101 | ! [ -e "$FBSENDEROTHERFILE" ] \ |
paul@804 | 102 | || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDEROTHERFILE" \ |
paul@804 | 103 | && ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBSENDEROTHERFILE" ) \ |
paul@804 | 104 | && echo "Success" \ |
paul@804 | 105 | || echo "Failed" |
paul@804 | 106 | |
paul@866 | 107 | grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T160000' "$STORE/$SENDER/objects/event6@example.com" \ |
paul@804 | 108 | && echo "Success" \ |
paul@804 | 109 | || echo "Failed" |
paul@804 | 110 | |
paul@804 | 111 | grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T170000' "$STORE/$SENDER/counters/objects/event6@example.com/$USER" \ |
paul@804 | 112 | && echo "Success" \ |
paul@804 | 113 | || echo "Failed" |
paul@804 | 114 | |
paul@804 | 115 | grep -q 'event6@example.com' "$FBSENDERREQUESTS" \ |
paul@804 | 116 | && echo "Success" \ |
paul@804 | 117 | || echo "Failed" |
paul@804 | 118 | |
paul@804 | 119 | # Check the free/busy state of the recipient so far. |
paul@804 | 120 | |
paul@804 | 121 | "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person-all.txt" 2>> $ERROR \ |
paul@804 | 122 | | "$SHOWMAIL" \ |
paul@804 | 123 | > out4.tmp |
paul@804 | 124 | |
paul@804 | 125 | grep -q 'METHOD:REPLY' out4.tmp \ |
paul@804 | 126 | && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T150000Z/20141126T160000Z' out4.tmp \ |
paul@804 | 127 | && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T160000Z/20141126T170000Z' out4.tmp \ |
paul@804 | 128 | && echo "Success" \ |
paul@804 | 129 | || echo "Failed" |
paul@804 | 130 | |
paul@804 | 131 | # Decline the counter-proposal. |
paul@804 | 132 | |
paul@804 | 133 | sed 's/COUNTER/DECLINECOUNTER/' < out2.tmp \ |
paul@804 | 134 | | sed 's/^From: calendar/To: vincent.vole/' \ |
paul@804 | 135 | | sed 's/^To: paul.boddie/From: paul.boddie/' \ |
paul@804 | 136 | > out5.tmp |
paul@804 | 137 | |
paul@804 | 138 | "$OUTGOING_SCRIPT" $ARGS < out5.tmp 2>> $ERROR |
paul@804 | 139 | |
paul@804 | 140 | ! [ -e "$STORE/$SENDER/counters/objects/event6@example.com/$USER" ] \ |
paul@804 | 141 | && echo "Success" \ |
paul@804 | 142 | || echo "Failed" |
paul@804 | 143 | |
paul@804 | 144 | ! grep -q 'event6@example.com' "$FBSENDERREQUESTS" \ |
paul@804 | 145 | && echo "Success" \ |
paul@804 | 146 | || echo "Failed" |
paul@804 | 147 | |
paul@804 | 148 | "$PERSON_SCRIPT" $ARGS < out5.tmp 2>> $ERROR \ |
paul@804 | 149 | | "$SHOWMAIL" \ |
paul@804 | 150 | > out6.tmp |
paul@804 | 151 | |
paul@804 | 152 | ! [ -e "$FBFILE" ] \ |
paul@804 | 153 | || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \ |
paul@804 | 154 | && ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBFILE" ) \ |
paul@804 | 155 | && echo "Success" \ |
paul@804 | 156 | || echo "Failed" |
paul@804 | 157 | |
paul@804 | 158 | ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBOFFERFILE" \ |
paul@804 | 159 | && ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBOFFERFILE" \ |
paul@804 | 160 | && echo "Success" \ |
paul@804 | 161 | || echo "Failed" |