From 2b532b540f448f02d7aee7ff04fa3d31655e7f8f Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Thu, 10 May 2012 15:06:06 -0500
Subject: ncid: reintroduction to repo

---
 abs/core/ncid/PKGBUILD            | 39 ++++++++++++++++++++++++++++++
 abs/core/ncid/ncid-linhes         | 33 +++++++++++++++++++++++++
 abs/core/ncid/ncid.install        | 17 +++++++++++++
 abs/core/ncid/ncid.py             | 35 +++++++++++++++++++++++++++
 abs/core/ncid/ncid.sql            | 51 +++++++++++++++++++++++++++++++++++++++
 abs/core/ncid/ncidclient.sh       |  2 ++
 abs/core/ncid/ncidpermissions.sql |  8 ++++++
 7 files changed, 185 insertions(+)
 create mode 100644 abs/core/ncid/PKGBUILD
 create mode 100644 abs/core/ncid/ncid-linhes
 create mode 100644 abs/core/ncid/ncid.install
 create mode 100644 abs/core/ncid/ncid.py
 create mode 100644 abs/core/ncid/ncid.sql
 create mode 100644 abs/core/ncid/ncidclient.sh
 create mode 100644 abs/core/ncid/ncidpermissions.sql

diff --git a/abs/core/ncid/PKGBUILD b/abs/core/ncid/PKGBUILD
new file mode 100644
index 0000000..9a468e8
--- /dev/null
+++ b/abs/core/ncid/PKGBUILD
@@ -0,0 +1,39 @@
+pkgname=ncid
+pkgver=0.83
+pkgrel=1
+pkgdesc="daemon to display callerid"
+url="http://ncid.sourceforge.net/"
+license=""
+depends=(python)
+makedepends=()
+conflicts=()
+replaces=()
+backup=()
+arch=('i686')
+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.py ncidpermissions.sql ncid.sql ncid-linhes)
+
+build() {
+   cd $startdir/src/$pkgname
+#  ./configure --prefix=/usr
+  make clean
+  make package  || return 1
+  }
+package(){
+  cd $startdir/src/$pkgname
+  #sed out MakeFILE
+
+  sed  -i "s|^.*\$(MAKE) install prefix=/usr prefix2=|\t\$(MAKE) install prefix=${pkgdir}/usr prefix2=$pkgdir|" Makefile
+  make package-install
+  install -m 755 $startdir/src/ncid-linhes $startdir/pkg/usr/share/ncid
+  install -m 755  $startdir/src/ncid.py   $startdir/pkg/usr/bin
+  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  
+  chmod 777 $startdir/pkg/tmp
+}
+md5sums=('710de8ab6d61ae48bd6e6ba159e95222'
+         'd4d51f0025baae4d6e0cd51d9dbd3a11'
+         '7655255b35a4fcdc0645c4f9018c1ed1'
+         'dbb9688e9af3fe60a0082c81db067d4a'
+         'dfb2f34dc6102f35765acb7aa881ec89')
diff --git a/abs/core/ncid/ncid-linhes b/abs/core/ncid/ncid-linhes
new file mode 100644
index 0000000..1a9e74c
--- /dev/null
+++ b/abs/core/ncid/ncid-linhes
@@ -0,0 +1,33 @@
+#!/bin/sh
+# keep "ncid-" in the name
+# input is 6 lines obtained from ncid
+# input: DATE\nTIME\nNUMBER\nNAME\nLINE\nTYPE\n
+#
+# input is 6 lines if a message was sent
+# input: \n\n\n<MESSAGE>\n\nMSG\n
+# Message will be in $CIDNAME
+#
+# ncid usage:
+#   ncid --no-gui [--message] --program ncid-linhes
+
+# $CIDTYPE is one of:
+#   CID: incoming call
+#   OUT: outgoing call
+#   HUP: blacklisted hangup
+#   MSG: message instead of a call
+
+ConfigDir=/etc/ncid
+ConfigFile=$ConfigDir/ncidmodules.conf
+
+[ -f $ConfigFile ] && . $ConfigFile
+
+read CIDDATE
+read CIDTIME
+read CIDNMBR
+read CIDNAME
+read CIDLINE
+read CIDTYPE
+
+#echo "$CIDDATE|$CIDTIME|$CIDNMBR|$CIDNAME|$CIDLINE|$CIDTYPE" > /dev/tty
+/usr/LH/bin/lh_message.sh "$CIDNMBR\n$CIDNAME\n$CIDTYPE"
+exit 0
diff --git a/abs/core/ncid/ncid.install b/abs/core/ncid/ncid.install
new file mode 100644
index 0000000..e000b3b
--- /dev/null
+++ b/abs/core/ncid/ncid.install
@@ -0,0 +1,17 @@
+
+post_install() {
+	
+        mysql -u root -e 'create database ncid;'  
+	echo installing the default database
+	mysql ncid < /tmp/ncid.sql 
+	mysql < /tmp/ncidpermissions.sql
+	rm /tmp/ncid.sql
+	rm /tmp/ncidpermissions.sql
+}
+post_upgrade() {
+	echo "nothing to do"
+}
+
+op=$1 
+shift 
+$op $*
diff --git a/abs/core/ncid/ncid.py b/abs/core/ncid/ncid.py
new file mode 100644
index 0000000..1301da1
--- /dev/null
+++ b/abs/core/ncid/ncid.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+
+import MySQLdb
+import sys
+import getopt
+import socket
+import os
+cdb = MySQLdb.connect(host="127.0.0.1", user="mythtv", passwd="mythtv", db="ncid")
+#log to logger?
+
+
+
+#log to db
+
+def main(argv):
+
+    DATE=sys.stdin.readline().strip()
+    TIME=sys.stdin.readline().strip()
+    NUMBER=sys.stdin.readline().strip()
+    NAME=sys.stdin.readline().strip()
+
+
+    #print "start of line"
+    #print DATE
+    #print TIME
+    #print NUMBER
+    #print NAME
+    #print "$$$$$$$$$$$$$$$$$$"
+    ncursor=cdb.cursor()
+    ncursor.execute ("""INSERT INTO cid (date,time,name,number) VALUES
+                    ('%s', '%s','%s','%s');""" %(DATE,TIME,NAME,NUMBER ))
+
+if __name__ == "__main__":
+    main(sys.argv[1:])
+
diff --git a/abs/core/ncid/ncid.sql b/abs/core/ncid/ncid.sql
new file mode 100644
index 0000000..556b4ba
--- /dev/null
+++ b/abs/core/ncid/ncid.sql
@@ -0,0 +1,51 @@
+-- MySQL dump 10.11
+--
+-- Host: localhost    Database: ncid
+-- ------------------------------------------------------
+-- Server version	5.0.27
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Table structure for table `cid`
+--
+
+DROP TABLE IF EXISTS `cid`;
+CREATE TABLE `cid` (
+  `id` int(11) NOT NULL auto_increment,
+  `date` varchar(36) NOT NULL default '',
+  `time` varchar(32) default NULL,
+  `name` varchar(32) default NULL,
+  `number` 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;
+
+--
+-- Dumping data for table `cid`
+--
+
+LOCK TABLES `cid` WRITE;
+/*!40000 ALTER TABLE `cid` DISABLE KEYS */;
+/*!40000 ALTER TABLE `cid` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+-- Dump completed on 2007-10-29 14:36:50
diff --git a/abs/core/ncid/ncidclient.sh b/abs/core/ncid/ncidclient.sh
new file mode 100644
index 0000000..0d2be3f
--- /dev/null
+++ b/abs/core/ncid/ncidclient.sh
@@ -0,0 +1,2 @@
+ncid --no-gui --all  --call-prog --program /usr/bin/ncid.py 127.0.0.1 3333
+
diff --git a/abs/core/ncid/ncidpermissions.sql b/abs/core/ncid/ncidpermissions.sql
new file mode 100644
index 0000000..eb660fa
--- /dev/null
+++ b/abs/core/ncid/ncidpermissions.sql
@@ -0,0 +1,8 @@
+ 
+GRANT ALL ON ncid.* TO mythtv@localhost IDENTIFIED BY "mythtv";
+GRANT ALL ON ncid.* TO mythtv@"%" IDENTIFIED BY "mythtv";
+GRANT FILE ON *.* TO 'mythtv'@'%';
+FLUSH PRIVILEGES;
+
+FLUSH PRIVILEGES;
+ALTER DATABASE ncid DEFAULT CHARACTER SET latin1;
-- 
cgit v0.12

