Skip to content
Snippets Groups Projects
Commit 07cfaaf2 authored by Johan Schön's avatar Johan Schön
Browse files

Added handling of unread texts in Membership

Rev: lib/modules/Protocols.pmod/LysKOM.pmod/Session.pike:1.7
parent fed6fb1c
No related branches found
No related tags found
No related merge requests found
// $Id: Session.pike,v 1.6 1999/07/19 16:03:54 mirar Exp $
// $Id: Session.pike,v 1.7 1999/09/28 02:08:59 js Exp $
//! module Protocols
//! submodule LysKOM
//! class Session
......@@ -452,6 +452,8 @@ class Membership
object conf;
object err;
void create(object mb,int pers)
{
person=pers;
......@@ -472,16 +474,63 @@ class Membership
}
}
// FETCHER(unread,ProtocolTypes.TextMapping,_unread,local_to_global,@({conf->no,1,255}))
int number_unread()
{
return (conf->no_of_texts+conf->first_local_no-1)
-last_text_read -sizeof(read_texts);
}
array(Text) _unread_texts;
array(object) get_unread_texts_blocking()
{
int i=last_text_read+1;
mapping(int:int) local_to_global = ([]);
if(i > conf->no_of_texts)
return (_unread_texts = ({ }) );
/* Get all the global numbers after last-text-read */
while(1)
{
ProtocolTypes.TextMapping textmapping=con->local_to_global(conf->no,i,255);
ProtocolTypes.LocalToGlobalBlock block=textmapping->block;
if(block->densep) /* Use TextList */
{
ProtocolTypes.TextList textlist=block->dense;
int j=textmapping->range_begin;
foreach(textlist->texts, int global)
local_to_global[j++]=global;
}
else /* Use array(TextNumberPair) */
{
foreach(block->sparse, ProtocolTypes.TextNumberPair pair)
local_to_global[pair->local_number]=pair->global_number;
}
if(!textmapping->later_texts_exists)
break;
i=textmapping->range_end;
}
mapping unread_numbers =
local_to_global -
mkmapping(read_texts,allocate(sizeof(read_texts)));
return /*_unread_texts =*/ map( sort(values(local_to_global)), text );
}
mixed `[](string what)
{
switch (what)
{
case "unread_texts":
return _unread_texts || get_unread_texts_blocking();
case "last_time_read":
case "read_texts":
case "last_text_read":
......@@ -492,8 +541,12 @@ class Membership
case "type":
case "number_unread":
return ::`[](what);
}
}
mixed `->(string what) { return `[](what); }
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment