From c9384ea38e51b5efc4ce9d88130c8b52db0926e2 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Thu, 4 Oct 2012 17:17:20 -0500
Subject: ncid: fix up to: 1) work 2) added area code lookup for US only

---
 abs/core/ncid/PKGBUILD                        | 20 +++++++++++---------
 abs/core/ncid/ncid-linhes                     | 20 +++++++++++++++++++-
 abs/core/ncid/ncid-log.py                     |  9 +++++----
 abs/core/ncid/ncid.sql                        |  1 +
 abs/core/supplemental-web/contents/calllog.py | 16 ++++++++--------
 abs/core/system-templates/PKGBUILD            |  2 +-
 6 files changed, 45 insertions(+), 23 deletions(-)
 mode change 100644 => 100755 abs/core/ncid/PKGBUILD

diff --git a/abs/core/ncid/PKGBUILD b/abs/core/ncid/PKGBUILD
old mode 100644
new mode 100755
index dbf5daa..6e09ef8
--- a/abs/core/ncid/PKGBUILD
+++ b/abs/core/ncid/PKGBUILD
@@ -1,19 +1,19 @@
 pkgname=ncid
-pkgver=0.83
+pkgver=0.84
 pkgrel=1
 pkgdesc="daemon to display callerid"
 url="http://ncid.sourceforge.net/"
 license=""
-depends=(python)
+depends=(python2)
 makedepends=()
 conflicts=()
 replaces=()
 backup=()
-arch=('i686')
+arch=('i686' 'x86_64' )
 install=ncid.install
 #source=(http://voxel.dl.sourceforge.net/project/ncid/ncid/$pkgver/$pkgname-$pkgver-src.tar.gz  ncidd.conf ncid.conf ncid.py ncidpermissions.sql ncid.sql)
 source=(http://voxel.dl.sourceforge.net/project/ncid/ncid/$pkgver/$pkgname-$pkgver-src.tar.gz ncid-log.py ncidpermissions.sql ncid.sql ncid-linhes)
-
+#must be built with -j 1
 build() {
    cd $startdir/src/$pkgname
 #  ./configure --prefix=/usr
@@ -25,15 +25,17 @@ package(){
   #sed out MakeFILE
 
   sed  -i "s|^.*\$(MAKE) install prefix=/usr prefix2=|\t\$(MAKE) install prefix=${pkgdir}/usr prefix2=$pkgdir|" Makefile
+  #sed  -i "s|^.*\$(MAKE) install prefix=/usr prefix2=|\t\$(MAKE) install prefix=${pkgdir}/usr prefix2=|" Makefile
+  mkdir -p ${pkgdir}/etc
   make package-install
   install -m 755 $startdir/src/ncid-linhes $startdir/pkg/usr/share/ncid
   install -m 755  $startdir/src/ncid-log.py   $startdir/pkg/usr/bin/ncid-log.py
   install -m 755 -D  $startdir/src/ncid.sql  $startdir/pkg/tmp/ncid.sql
-  install -m 755 -D $startdir/src/ncidpermissions.sql  $startdir/pkg/tmp/ncidpermissions.sql  
+  install -m 755 -D $startdir/src/ncidpermissions.sql  $startdir/pkg/tmp/ncidpermissions.sql
   chmod 777 $startdir/pkg/tmp
 }
-md5sums=('710de8ab6d61ae48bd6e6ba159e95222'
-         'd4d51f0025baae4d6e0cd51d9dbd3a11'
+md5sums=('4451cb67bd13899e3f98aeda8d8e4f40'
+         'd921bc210d5fa63855edd6c0e0102f68'
          '7655255b35a4fcdc0645c4f9018c1ed1'
-         'dbb9688e9af3fe60a0082c81db067d4a'
-         'dfb2f34dc6102f35765acb7aa881ec89')
+         'b7a95f89fe5cb46e50ff25df7adc18b4'
+         'abc3db9c6676b89081d5d412e46772a3')
diff --git a/abs/core/ncid/ncid-linhes b/abs/core/ncid/ncid-linhes
index 1a9e74c..faa1056 100644
--- a/abs/core/ncid/ncid-linhes
+++ b/abs/core/ncid/ncid-linhes
@@ -15,6 +15,8 @@
 #   OUT: outgoing call
 #   HUP: blacklisted hangup
 #   MSG: message instead of a call
+MYTH_RUN_STATUS=1
+. /etc/profile
 
 ConfigDir=/etc/ncid
 ConfigFile=$ConfigDir/ncidmodules.conf
@@ -28,6 +30,22 @@ read CIDNAME
 read CIDLINE
 read CIDTYPE
 
+LOC=''
+
+#areacode=`echo $CIDNMBR | cut -d "(" -f2 | cut -d ")" -f1`
+areacode=`echo $CIDNMBR | cut -d "-" -f1`
+if [ -e $MV_ROOT/templates/ncid/areacodes.csv ]
+then
+    LOC=`grep $areacode $MV_ROOT/templates/ncid/areacodes.csv  |cut -d ","  -f2`
+fi
+
+
+
+
 #echo "$CIDDATE|$CIDTIME|$CIDNMBR|$CIDNAME|$CIDLINE|$CIDTYPE" > /dev/tty
-/usr/LH/bin/lh_message.sh "$CIDNMBR\n$CIDNAME\n$CIDTYPE"
+
+/usr/LH/bin/msg_client.py --clear
+/usr/LH/bin/msg_client.py --kill
+sleep .2
+/usr/LH/bin/msg_client.py --msg "$CIDNMBR\n$CIDNAME\n$CIDTYPE\n$LOC"
 exit 0
diff --git a/abs/core/ncid/ncid-log.py b/abs/core/ncid/ncid-log.py
index 1301da1..64006df 100644
--- a/abs/core/ncid/ncid-log.py
+++ b/abs/core/ncid/ncid-log.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python2
 
 import MySQLdb
 import sys
@@ -18,7 +18,8 @@ def main(argv):
     TIME=sys.stdin.readline().strip()
     NUMBER=sys.stdin.readline().strip()
     NAME=sys.stdin.readline().strip()
-
+    LINE=sys.stdin.readline().strip()
+    TYPE=sys.stdin.readline().strip()
 
     #print "start of line"
     #print DATE
@@ -27,8 +28,8 @@ def main(argv):
     #print NAME
     #print "$$$$$$$$$$$$$$$$$$"
     ncursor=cdb.cursor()
-    ncursor.execute ("""INSERT INTO cid (date,time,name,number) VALUES
-                    ('%s', '%s','%s','%s');""" %(DATE,TIME,NAME,NUMBER ))
+    ncursor.execute ("""INSERT INTO cid (date,time,name,number,calltype) VALUES
+                    ('%s', '%s','%s','%s','%s');""" %(DATE,TIME,NAME,NUMBER,TYPE ))
 
 if __name__ == "__main__":
     main(sys.argv[1:])
diff --git a/abs/core/ncid/ncid.sql b/abs/core/ncid/ncid.sql
index 556b4ba..bcef947 100644
--- a/abs/core/ncid/ncid.sql
+++ b/abs/core/ncid/ncid.sql
@@ -26,6 +26,7 @@ CREATE TABLE `cid` (
   `time` varchar(32) default NULL,
   `name` varchar(32) default NULL,
   `number` varchar(32) default NULL,
+  `calltype` varchar(32) default NULL,
   `ts` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
   PRIMARY KEY  (`id`)
 ) ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=latin1;
diff --git a/abs/core/supplemental-web/contents/calllog.py b/abs/core/supplemental-web/contents/calllog.py
index 908a9c6..9a13e14 100644
--- a/abs/core/supplemental-web/contents/calllog.py
+++ b/abs/core/supplemental-web/contents/calllog.py
@@ -17,29 +17,29 @@ def main(argv):
     cursor.execute("select  name,number,count(number) as '# calls'  from cid group by number,name  order by '# calls' DESC  limit 20;")
     result = cursor.fetchall()
 
-    
-#Top shows  
+
+#Top shows
     #print '<div id="content"> <p></p>'
     print '<div> <p></p>'
     print '<table class="calllog">'
     print "Top 20 callers"
     searchstring='''<td> <a href="http://www.google.com/search?q=%s" >  %s  </a> </td> '''
-    cursor.execute("select  name,number,count(number) as '# calls'  from cid group by number,name  order by '# calls' DESC  limit 20;")
+    cursor.execute("select  name,number,count(number)  from cid group by number,name  order by count(number) DESC  limit 20;")
     result = cursor.fetchall()
     for row in result:
         print "	<tr>"
         #print "		<td>",row[0],"</td>"
-        print  searchstring  % (row[0], row [0]) 	
+        print  searchstring  % (row[0], row [0])
         print "		<td>",row[2],"</td>"
         #print "		<td>",row[1],"</td>"
-        print  searchstring  % (row[1], row [1]) 	
+        print  searchstring  % (row[1], row [1])
         print "	</tr>"
         #print "%40s %26s %10s" %(row[0],row[2],row[1])
     print "</table>"
     print "</div>"
 #Top categorys
 
-    
+
     print '<br>'
     print '<br>'
     #print '<div id="content"> <p></p>'
@@ -54,9 +54,9 @@ def main(argv):
         print "		<td>  %s  </td>" %(row[0])
         print "		<td>",row[1],"</td>"
         #print "		<td>",row[2],"</td>"
-        print  searchstring  % (row[2], row [2]) 	
+        print  searchstring  % (row[2], row [2])
         #print "		<td>",row[3],"</td>"
-        print  searchstring  % (row[3], row [3]) 	
+        print  searchstring  % (row[3], row [3])
         print "	</tr>"
 #        print "%26s %26s %26s %26s " %(row[0],row[1],row[2],row[3])
     print "</table>"
diff --git a/abs/core/system-templates/PKGBUILD b/abs/core/system-templates/PKGBUILD
index 51eb627..f9a706b 100755
--- a/abs/core/system-templates/PKGBUILD
+++ b/abs/core/system-templates/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=system-templates
 pkgver=2.0
-pkgrel=18
+pkgrel=19
 conflicts=( )
 pkgdesc="Templates used for system configuration"
 depends=()
-- 
cgit v0.12

