[asterisk-commits] trunk r12232 - in /trunk: apps/ contrib/scripts/ include/asterisk/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Mar 6 18:12:11 MST 2006


Author: tilghman
Date: Mon Mar  6 19:12:09 2006
New Revision: 12232

URL: http://svn.digium.com/view/asterisk?rev=12232&view=rev
Log:
Bug 5702 - Realtime patch for meetme

Added:
    trunk/contrib/scripts/meetme.sql   (with props)
Modified:
    trunk/apps/app_meetme.c
    trunk/include/asterisk/config.h

Modified: trunk/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_meetme.c?rev=12232&r1=12231&r2=12232&view=diff
==============================================================================
--- trunk/apps/app_meetme.c (original)
+++ trunk/apps/app_meetme.c Mon Mar  6 19:12:09 2006
@@ -1,3 +1,4 @@
+
 /*
  * Asterisk -- An open source telephony toolkit.
  *
@@ -147,9 +148,9 @@
 	struct ast_conf_user *firstuser;	/* Pointer to the first user struct */
 	struct ast_conf_user *lastuser;		/* Pointer to the last user struct */
 	time_t start;				/* Start time (s) */
-	int recording;				/* recording status */
-	int isdynamic;				/* Created on the fly? */
-	int locked;				/* Is the conference locked? */
+	unsigned int recording:2;				/* recording status */
+	unsigned int isdynamic:1;				/* Created on the fly? */
+	unsigned int locked:1;				/* Is the conference locked? */
 	pthread_t recordthread;			/* thread for recording */
 	pthread_attr_t attr;			/* thread attribute */
 	const char *recordingfilename;		/* Filename to record the Conference into */
@@ -518,7 +519,7 @@
 			/* Fill the conference struct */
 			cnf->start = time(NULL);
 			cnf->zapconf = ztc.confno;
-			cnf->isdynamic = dynamic;
+			cnf->isdynamic = dynamic ? 1 : 0;
 			cnf->firstuser = NULL;
 			cnf->lastuser = NULL;
 			cnf->locked = 0;
@@ -851,6 +852,7 @@
 	char meetmesecs[30] = "";
 	char exitcontext[AST_MAX_CONTEXT] = "";
 	char recordingtmp[AST_MAX_EXTENSION] = "";
+	char members[10] = "";
 	int dtmf;
 	ZT_BUFFERINFO bi;
 	char __buf[CONF_SIZE + AST_FRIENDLY_OFFSET];
@@ -920,6 +922,10 @@
 	user->adminflags = 0;
 	user->talking = -1;
 	conf->users++;
+	/* Update table */
+	snprintf(members, sizeof(members), "%d", conf->users);
+	ast_update_realtime("meetme", "confno", conf->confno, "members", members , NULL);
+
 	ast_mutex_unlock(&conf->playlock);
 
 	if (confflags & CONFFLAG_EXIT_CONTEXT) {
@@ -1665,6 +1671,9 @@
 		          "<no name>", hr, min, sec);
 
 		conf->users--;
+		/* Update table */
+		snprintf(members, sizeof(members), "%d", conf->users);
+		ast_update_realtime("meetme", "confno", conf->confno, "members", members, NULL);
 		if (confflags & CONFFLAG_MARKEDUSER) 
 			conf->markedusers--;
 		if (!conf->users) {
@@ -1708,6 +1717,52 @@
 
 	return ret;
 }
+
+/*
+  This function looks for a conference via the RealTime module
+*/
+static struct ast_conference *find_conf_realtime(struct ast_channel *chan, char *confno, int make, int dynamic, char *dynamic_pin)
+{
+
+	struct ast_variable *var;
+	struct ast_conference *cnf;
+
+	/* Check first in the conference list */
+	AST_LIST_LOCK(&confs);
+	AST_LIST_TRAVERSE(&confs, cnf, list) {
+		if (!strcmp(confno, cnf->confno)) 
+			break;
+	}
+	AST_LIST_UNLOCK(&confs);
+
+	if (!cnf) {
+		char *pin = NULL, *pinadmin = NULL; /* For temp use */
+
+		cnf = ast_calloc(1, sizeof(struct ast_conference));
+		if (!cnf) {
+			ast_log(LOG_ERROR, "Out of memory\n");
+			return NULL;
+		}
+
+		var = ast_load_realtime("meetme", "confno", confno, NULL);
+		while (var) {
+			if (!strcasecmp(var->name, "confno")) {
+				ast_copy_string(cnf->confno, var->value, sizeof(cnf->confno));
+			} else if (!strcasecmp(var->name, "pin")) {
+				pin = ast_strdupa(var->value);
+			} else if (!strcasecmp(var->name, "adminpin")) {
+				pinadmin = ast_strdupa(var->value);
+			}
+			var = var->next;
+		}
+		ast_variables_destroy(var);
+
+		cnf = build_conf(confno, pin ? pin : "", pinadmin ? pinadmin : "", make, dynamic);
+	}
+
+	return cnf;
+}
+
 
 static struct ast_conference *find_conf(struct ast_channel *chan, char *confno, int make, int dynamic, char *dynamic_pin)
 {
@@ -2007,6 +2062,9 @@
 			/* Check the validity of the conference */
 			cnf = find_conf(chan, confno, 1, dynamic, the_pin);
 			if (!cnf) {
+				cnf = find_conf_realtime(chan, confno, 1, dynamic, the_pin);
+			}
+			if (!cnf) {
 				res = ast_streamfile(chan, "conf-invalid", chan->language);
 				if (!res)
 					ast_waitstream(chan, "");

Added: trunk/contrib/scripts/meetme.sql
URL: http://svn.digium.com/view/asterisk/trunk/contrib/scripts/meetme.sql?rev=12232&view=auto
==============================================================================
--- trunk/contrib/scripts/meetme.sql (added)
+++ trunk/contrib/scripts/meetme.sql Mon Mar  6 19:12:09 2006
@@ -1,0 +1,12 @@
+-- 
+-- Table structure for Realtime meetme
+-- 
+
+CREATE TABLE meetme (
+	confno char(80) DEFAULT '0' NOT NULL,
+	pin char(20) NULL,
+	adminpin char(20) NULL,
+	members integer DEFAULT 0 NOT NULL,
+	PRIMARY KEY (confno)
+);
+

Propchange: trunk/contrib/scripts/meetme.sql
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/contrib/scripts/meetme.sql
------------------------------------------------------------------------------
    svn:keywords = Author Id Date Revision

Propchange: trunk/contrib/scripts/meetme.sql
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: trunk/include/asterisk/config.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/config.h?rev=12232&r1=12231&r2=12232&view=diff
==============================================================================
--- trunk/include/asterisk/config.h (original)
+++ trunk/include/asterisk/config.h Mon Mar  6 19:12:09 2006
@@ -124,7 +124,7 @@
  * This will use builtin configuration backends to look up a particular 
  * entity in realtime and return a variable list of its parameters.  Note
  * that unlike the variables in ast_config, the resulting list of variables
- * MUST be fred with ast_free_runtime() as there is no container.
+ * MUST be freed with ast_variables_destroy() as there is no container.
  */
 struct ast_variable *ast_load_realtime(const char *family, ...);
 



More information about the asterisk-commits mailing list