Verified Commit 2be59c63 authored by Bernd Paysan's avatar Bernd Paysan
Browse files

Temporary problem for notify-send, fix sending out ihaves

parent 74cbe306
Loading
Loading
Loading
Loading
+40 −13
Original line number Diff line number Diff line
@@ -20,6 +20,23 @@
	    '<' of  ." &lt;"   endof
	    '>' of  ." &gt;"   endof
	    '&' of  ." &amp;"  endof
	    '"' of  ." &quot;" endof
	    emit  0 endcase  LOOP ;
: escape-<&>-shell ( addr u -- )
    bounds ?DO  case i c@
	    '<' of  ." &lt;"   endof
	    '>' of  ." &gt;"   endof
	    '&' of  ." &amp;"  endof
	    '"' of  ." &quot;" endof
	    '\' of  ." \\"     endof
	    '$' of  ." \$"     endof
	    '!' of  ." \!"     endof
	    emit  0 endcase  LOOP ;
: escape-shell ( addr u -- )
    bounds ?DO  case i c@
	    '\' of  ." \\"     endof
	    '$' of  ." \$"     endof
	    '!' of  ." \!"     endof
	    emit  0 endcase  LOOP ;

: build-notification ( -- ) ;
@@ -30,9 +47,9 @@
	ELSE  notify$ $@ ['] escape-<&> $tmp  THEN
    ELSE  "<i>encrypted message</i>"  THEN ;

: 0string ( addr u -- cstr )
    over 0= IF  2drop s" "  THEN
    1+ save-mem over + 1- 0 swap c! ;
: 0$! ( addr u cstr-addr -- )
    >r 1+ over 0= IF  2drop "\0"  THEN
    save-mem over + 1- 0 swap c! r> ! ;

0 Value content-string
0 Value title-string
@@ -61,7 +78,11 @@ $Variable net2o-logo
: !net2o-logo ( -- )
    s" ../doc/net2o-logo.png" fpath file>abspath net2o-logo $! ;

: ?free0 ( addr -- )
    dup 0= IF  drop  EXIT  THEN  @ free throw ;
: !notify-args ( -- )
    title-string   ?free0
    content-string ?free0
    here >r notify-args dp !
    "notify-send\0" drop ,
    "-a\0" drop ,
@@ -83,10 +104,16 @@ $Variable net2o-logo
    !upath !net2o-logo !notify-args ; is 'cold

: linux-notification ( -- )  notify-send $@len 0= ?EXIT
    title-string   0 ?free
    content-string 0 ?free
    [IFDEF] use-execve
	notify@ content-string 0$!
	['] notify-title $tmp dup 0= IF  2drop  EXIT  THEN  title-string 0$!
	notify-send $@ notify-args fork+exec
    [ELSE]
	[: notify-send $. space
	    ." -a net2o -c im.received "
	    net2o-logo $@len IF
		." -i " net2o-logo $. space  THEN
	    ['] notify-title $tmp dup 0= IF  2drop  EXIT  THEN
    notify@ dup 0= IF  2drop 2drop  EXIT  THEN
    0string content-string !
    0string title-string !
    notify-send $@ notify-args fork+exec ;
	    '"' emit escape-<&>-shell '"' emit space
	    '"' emit notify@ escape-shell '"' emit ;] $tmp system
    [THEN] ;
+6 −1
Original line number Diff line number Diff line
@@ -1376,7 +1376,12 @@ also net2o-base
    [: 2dup startdate@ 64#0 { 64^ sd } sd le-64!  sd 1 64s forth:type
	c:0key sigonly@ >hash hashtmp hash#128 forth:type ;] $tmp $, msg-chain ;
: ihave, ( -- )
    ihave$ $@ dup IF  $, mehave$ $@ $, msg-ihave  ELSE  2drop  THEN ;
    ihave$ $@ dup IF
	maxstring 4 - mehave$ $@len - dup 0< IF  2drop  EXIT  THEN
	keysize negate and dup >r
	$, mehave$ $@ $, msg-ihave
	ihave$ 0 r> $del
    ELSE  2drop  THEN ;
: push, ( -- )
    push$ $@ dup IF  $, nestsig  ELSE  2drop  THEN ;